从后面的代码调用javascript时如何设置返回值

时间:2016-10-18 11:40:25

标签: javascript asp.net

我有一个链接按钮,如下所示

<atoms:StoreLink Visible="<%# !ECommUtilities.HideTopSubmitOrderButtonCountries  %>"   OnServerClick="Continue_Clicked" Caption="<%# CheckoutCaption %>" localefile="ECOMM_CAPTION" runat="server" ID="_continue" AuthEnabled="false" OnClientClick="<%# GetVerifyIovationMethodNam %>" />

我的Javascript函数是

function preventDuobleClickEvent(element) {
            alert('Prevent');
            if (!isSubmit) {
                isSubmit = true;
                element.disabled = true;
                return true;
            }
            else {
                alert('elseCond');
                return false;
            }
        }

现在我怎样才能使我的Linkbutton客户端点击期望返回

我试过这个没用?

 <atoms:StoreLink Visible="<%# !ECommUtilities.HideTopSubmitOrderButtonCountries  %>"   OnServerClick="Continue_Clicked" Caption="<%# CheckoutCaption %>" localefile="ECOMM_CAPTION" runat="server" ID="_continue" AuthEnabled="false" OnClientClick="return<%# GetVerifyIovationMethodNam %>" />

1 个答案:

答案 0 :(得分:0)

简单方法是从代码后面设置OnClientClick值,因为它看起来好像要使用变量作为javascript的返回值。这是一个例子。

<asp:Button ID="Button1" runat="server" Text="Button" />

然后在代码背后:

Button1.OnClientClick = "return preventDuobleClickEvent('" + GetVerifyIovationMethodNam + "')";