[英]Calling a button click function using javascript in c#
Hi I am trying to call a button click function written within the c# code behind from javascript. 嗨,我正在尝试调用从JavaScript后面的C#代码中编写的按钮单击功能。 but its not triggering the button click function.
但它不会触发按钮点击功能。 I didnt find anything suspicious in the code.
我没有在代码中发现任何可疑的东西。 Please check and let me know what is actually blocking the call.
请检查并让我知道实际上是什么阻止了该呼叫。 These are my code scraps.
这些是我的代码残篇。
<script language="javascript" type="text/javascript">
function ConfirmFuncn() {
var Msge = document.getElementById('<%=hdnMsge.ClientID %>').value;
if (confirm(Msge)) {
document.getElementById('<%=hdnTestValue.ClientID %>').value = "true";
}
else {
document.getElementById('<%=hdnTestValue.ClientID %>').value = "false";
}
document.getElementById('<%=btnSaveHidden.ClientID %>').Click();
}
</script>
<asp:Button ID="btnSaveHidden" runat="server" Visible="false"
Text="HiddenSaveButton" onclick="btnSaveHidden_Click"
/>
Here it does not call btnSaveHidden_Click
. 在这里它不调用
btnSaveHidden_Click
。 Javascript function ConfirmFuncn
is calling properly, because i am getting the message value I set to hidden field. JavaScript函数
ConfirmFuncn
正在正确调用,因为我正在获取设置为隐藏字段的消息值。 But btnSaveHidden_Click
is not triggering. 但是
btnSaveHidden_Click
不会触发。 Why? 为什么?
it wont work when: 它在以下情况下不起作用:
Visible="False"
incited of hidden the button by it self just hide in indies a hidden div : 通过自身引发隐藏按钮,只是在印度隐藏了一个隐藏的div:
you can hide your button with hidden div 您可以使用隐藏的div隐藏按钮
<div style="display: none;">
<asp:Button ID="btnSaveHidden" runat="server" Visible="false"
Text="HiddenSaveButton" onclick="btnSaveHidden_Click" />
</div>
Use style="display: none;"
使用
style="display: none;"
instead of Visible="false"
而不是
Visible="false"
<asp:Button ID="btnSaveHidden" runat="server" style="display: none;"
Text="HiddenSaveButton" onclick="btnSaveHidden_Click" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.