您可以在查询字符串中传递消息和等待时间
Response.Redirect("new.aspx?Message=Your_Message&Time=3000")
在new.aspx的Page_Load中可以捕捉参数
string msg = Request["Message"]
string time = Request["Time"]
您需要用户等待 x 秒才能看到消息吗?
如果是,则需要通过 javascript 来完成。
首先,创建一个 javascript 函数来显示消息
function ShowMessage(msg) {
alert(msg);
}
然后,在new.aspx后面的代码中,获取参数并调用javascript函数
protected void Page_Load(object sender, EventArgs e)
{
string msg = Request["Message"].ToString();
string tempo = Request["Time"].ToString();
string script = String.Format(@"setTimeout(""ShowMessage('{0}')"", {1})", msg, tempo);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "key", script, true);
}
它将在 3 秒后显示消息。