显示成功消息和重定向问题 [英] Display success message and redirect problem
本文介绍了显示成功消息和重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码来显示成功的消息和重定向。成功的消息未显示但正在重定向到下一页。我做错了什么?
I have a code to display a successful message and redirect. The successful message is not displaying but it is redirecting to the next page. What did I do have wrong?
try
{
cmd.ExecuteScalar();
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('You Have Successfully Submitted the Enrollment Profile');", true);
con.Close();
Response.Redirect("Gradrate.aspx");
}
catch
{
}
< br $> b $ b
我尝试过不同的方式。它将显示消息但不重定向或重定向但不显示消息。请帮助!
I did try it different ways. it will show the message but not redirect or redirect but no message. Please Help!
推荐答案
您好b $ b
试试这样..
Hi
Try like this..
protected void btn_Click(object sender, EventArgs e)
{
string script = " <script type=\"text/javascript\"> alert('your message'); window.location='Gradrate.aspx'; </script> ";
// if u r using ajax, use the following line
//this.Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", script);
ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", script, false);
}
这篇关于显示成功消息和重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文