我想知道为什么Java脚本函数没有正确地返回确认值。
我有这个按钮:
<asp:Button ID="btnSaveAgreement" runat="server" UseSubmitBehavior="false" Text="Save" OnClientClick ="ConfirmSaveWithoutSendEmail(this);" />
我有这个Java脚本函数:
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;
}
}
为什么选择的确认值总是被认为是真?
我想知道我错过了什么。
https://stackoverflow.com/questions/52730943
复制相似问题