I have found StackOverFlow answers and other resources saying that you can click on a hidden ASP:Button with jQuery by
$("#<%=HiddenButton.ClientID%>").click();
or
$("#<%=HiddenButton.ClientID%>").trigger("click");
However, neither of these are working for me UNLESS the button is Visible="true"
Here is the button:
<asp:Button ID="loadCustomerContacts" runat="server" OnClick="loadCustomerContacts_Click" visible="false" />"
If you set the Visible
property to false; typically in .net the control will not be rendered in the HTML output after the page is processed. Therefore as far as jQuery is concerned, the button does not exist.
You can do a View Source on the page to verify this.
If you want to do this, instead of using the Visible
property, you can do something like:
<asp:Button ID="myButton" runat="server" style="visibility: hidden; display: none;" />
Or you can assign it a CSS class that hides it.
You need to add style="display:none" to the button instead of Visible=False
Coding Gorilla is right, however, what you can do is instead of setting the Visible property, add this to the tag instead:
style="display:none;"
This will hide the button in CSS instead of not rendering the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With