Question not firing on click event

josephjohn100

Member
Joined
Nov 8, 2012
Messages
8
Programming Experience
3-5
I'm using the style="display: none". The onClick event is called only in Firefox, but not in IE. the code is shown below

<asp:ButtonID="btnLogin"runat="server"style="display: none"Visible="true"Text="Search"OnClick="btnLogin_Click"/>

Please help.
 
Have you tried preventing the default click action? e.g.
VB.NET:
...onClick="btnLogin_Click();return false;"
 
Menthos, that button is a server control, OnClick attribute is for server-side event handler, while OnClientClick attribute is used for client-side scripts.

josephjohn100, you don't need the OnClick declaration, doubleclick the control in designer and it generates click event handler with a Handles clause. It would have the same meaning though, and I don't know what the issue you're having is.
 
Good point JohnH - obviously the caffeine isn't working this morning.

josephjohn100 - are you trying to call client side javascript or a server side method?
 
Yes , I tried removing the OnClick Declaration, and adding the click event handler. Still it is not working. looks like the problem is with style="display: none" in IE. When I remove that it is working good.But I need to hide that button and still fire that event. Thats why I tried style="display: none".
ANy other way , pls help ?
josephjohn100 - are you trying to call client side javascript or a server side method?
serverside method
 
I need to hide that button and still fire that event
That sounds very weird. To me it sounds as you want to make a postback by other means. The button click can't be relevant if the button is not displayed and can't be clicked.
 
If you want to execute that method manually, call the method from your server-side logic. There's obviously no client interaction, as you have it hidden.

Perhaps it would help if you explained what you're actually trying to achieve here - what logic/steps are involved?
 
Back
Top