I want to show message and reload page at same time,
But it has been kept reload page and can not stop.
How can I fix this problem? thanks.
protected void btnCk_Click(object sender, EventArgs e)
{
string a= Request.Form["a"];
string b= Request.Form["b"];
string c= Request.Form["c"];
string strReturn = null;
strReturn = U9.Data.LoginData.LoginChange(a, b, c);
if (strReturn == "0")
{
Response.Write("<Script language='JavaScript'>alert('OK');</Script>");
}
else
{
Response.Write("<Script language='JavaScript'>alert('"+ strReturn.ToString() + "');</Script>");
}
Response.Write("<Script language='JavaScript'>window.location.reload();</Script>");
Response.End();
}
I think this issue is because of you are you're trying with Response.Write
which writes a string to an HTTP response output stream.
In this case, you can use ClientScriptManager.RegisterStartupScript Method
if (strReturn == "0")
{
ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('OK');window.location='default.aspx';", true);
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('"+ strReturn.ToString() + "');window.location='default.aspx';", true);
}
And change your page at the place of default.aspx
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.