问题描述
我找到了StackOverFlow的答案和其他资源,说您可以单击带有jQuery的隐藏的ASP:Button
I have found StackOverFlow answers and other resources saying that you can click on a hidden ASP:Button with jQuery by
$("#<%=HiddenButton.ClientID%>").click();
或
$("#<%=HiddenButton.ClientID%>").trigger("click");
但是,除非按钮为Visible ="true"
However, neither of these are working for me UNLESS the button is Visible="true"
这里是按钮:
<asp:Button ID="loadCustomerContacts" runat="server" OnClick="loadCustomerContacts_Click" visible="false" />"
推荐答案
如果将 Visible
属性设置为false;通常在.net中,处理页面后,控件将不会在HTML输出中呈现.因此,就jQuery而言,该按钮不存在.
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.
如果要执行此操作,可以使用以下方法代替使用 Visible
属性:
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;" />
或者您可以为其分配一个隐藏它的CSS类.
Or you can assign it a CSS class that hides it.
这篇关于如果使用jQuery隐藏了ASP:Button,我将无法单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!