首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在JavaScript函数中检索“Asp.net ()”值时出现确认问题

在JavaScript函数中检索“Asp.net ()”值时出现确认问题
EN

Stack Overflow用户
提问于 2018-10-10 08:16:58
回答 1查看 66关注 0票数 1

我想知道为什么Java脚本函数没有正确地返回确认值。

我有这个按钮:

代码语言:javascript
复制
<asp:Button ID="btnSaveAgreement" runat="server" UseSubmitBehavior="false" Text="Save" OnClientClick ="ConfirmSaveWithoutSendEmail(this);" />

我有这个Java脚本函数:

代码语言:javascript
复制
 function ConfirmSaveWithoutSendEmail(btnToDisableWhileSubmitting)
    {           
        var IsPanelToSendEmailVisible = document.getElementById('<%= hfIsSendEmailPanelVisible.ClientID%>').value; 

        if (IsPanelToSendEmailVisible > 0)
        {
            //This section takes a confirmation "Ok/Cancel" to submit or not 
            //the data, the problem is that if I choose "Cancel", the code 
            //on the button is executed, the behavior I would except is such 
            //that selecting "Cancel"  the code on my button is not 
            //executed.

            return confirm("Do you want to save without send email?");
        }
        else
        {                
            //this section disable the button while submitting information, 
            //this section works fine.

            if (!Page_ClientValidate())
                return false;

            btnToDisableWhileSubmitting.disabled = true;
            btnToDisableWhileSubmitting.value = 'Saving...';
            return true;
        }
      }

为什么选择的确认值总是被认为是真?

我想知道我错过了什么。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52730943

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档