ASP.NET中一个页面转到另外一个页面的问题

来源:百度知道 编辑:UC知道 时间:2024/07/06 18:59:10
SqlCommand cmd = new SqlCommand(sql, conn);
if(cmd.ExecuteNonQuery())
{
Response.Write("<script language='javascript'>alert('提交成功!');</script>");
Response.Redirect("liuyan.aspx");
}
else
{
Response.Write("<script language='javascript'>alert('提交不成功!请重新提交');</script>");
}

我的本意是,提交成功后点击确定,转到liuyan.aspx页面,但是上面的代码,连提交成功都没提示就直接转到liuyan.aspx页面了.怎么做才能让它点击确定然后再转到另外一个页面.

/// <summary>
/// 弹出提示并转向url
/// </summary>
/// <param name="message"></param>
/// <param name="url"></param>
protected void MsgBox(string message, string url)
{
ClientScriptManager cs = Page.ClientScript;
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";
Type cstype = this.GetType();

// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert('" + Server.HtmlEncode(message) + "');window.location='" + url + "';";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
}