[英]How to set return value when javascript called from code behind
I have a link button as below 我有一个链接按钮,如下所示
<atoms:StoreLink Visible="<%# !ECommUtilities.HideTopSubmitOrderButtonCountries %>" OnServerClick="Continue_Clicked" Caption="<%# CheckoutCaption %>" localefile="ECOMM_CAPTION" runat="server" ID="_continue" AuthEnabled="false" OnClientClick="<%# GetVerifyIovationMethodNam %>" />
my Javascript function is 我的Javascript函数是
function preventDuobleClickEvent(element) {
alert('Prevent');
if (!isSubmit) {
isSubmit = true;
element.disabled = true;
return true;
}
else {
alert('elseCond');
return false;
}
}
now how can i make so that my Linkbutton client click is expecting a return 现在我该如何做才能使我的Linkbutton客户端点击期望返回
I tried this It did not work 我尝试了这个没有用
<atoms:StoreLink Visible="<%# !ECommUtilities.HideTopSubmitOrderButtonCountries %>" OnServerClick="Continue_Clicked" Caption="<%# CheckoutCaption %>" localefile="ECOMM_CAPTION" runat="server" ID="_continue" AuthEnabled="false" OnClientClick="return<%# GetVerifyIovationMethodNam %>" />
The easies way is to set the OnClientClick
value from code behind since it looks like you want to use a variable as a return value for javascript. 简便的方法是从后面的代码中设置
OnClientClick
值,因为您似乎想将变量用作javascript的返回值。 Here is an example. 这是一个例子。
<asp:Button ID="Button1" runat="server" Text="Button" />
And then in code behind: 然后在后面的代码中:
Button1.OnClientClick = "return preventDuobleClickEvent('" + GetVerifyIovationMethodNam + "')";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.