我正在使用此代码。当我点击主页面上的按钮时会弹出这个弹出窗口。现在我想要在成功更改密码并重新加载主页面时关闭弹出窗口,但是如果密码未更改,然后再次刷新弹出窗口。
我使用javascript进行表单验证enter code here
这是代码.....
<asp:Textbox id="curnt_paswrd" textmode="Password" runat="server" size="30" />
<asp:Textbox id="new_paswrd" textmode="Password" runat="server" size="30" />
<asp:button ID="btnChange" class="submit-button"
OnClientClick="return validate()" runat="server" Text="Change"
onclick="btnChange_Click" />
答案 0 :(得分:1)
您可以这样简单地做:返回 true 后,主页将自动刷新。
function validate() {
var strOutput = window.showModalDialog('ChangePassword.aspx', null, "dialogWidth:750px; dialogHeight:190px; dialogHide:false; edge:raised; center:yes; help:no; scroll:no; status:no;resizable:no;");
if (strOutput == undefined)
return false;
else if (strOutput == '')
return false;
else return true;
}
在弹出页面上,使用javascript:
function IsSavePasswordSuccess()
{
window.returnValue = '<%=hdnSaveClickStatus.Value%>';
window.close();
}
隐藏字段将设置为。它将在您的C#方法中设置。
<asp:HiddenField runat="server" ID="hdnSaveClickStatus" />
答案 1 :(得分:0)
当您重新加载该弹出窗口时,如果更改成功,您可以在脚本中执行以下操作:
window.opener.location.reload();
window.close();
例如,使用RegisterStartupScript
:
ClientScript.RegisterStartupScript(GetType(), "CloseScript",
"window.opener.location.reload(); window.close();", true);