点击按钮页面回传
if (!IsPostBack)
{}
window.location.href
提示
ClientScript.RegisterStartupScript(this.GetType(), "js", "", true);
if (!IsPostBack)
{}
window.location.href
提示
ClientScript.RegisterStartupScript(this.GetType(), "js", "", true);
protected void Button1_Click(object sender, EventArgs e)
{
if(SaveData())
Response.Redirect("a.aspx",true);
else
{ //do what you want;}
}
如果你还想有保存成功之类的提示,你可以
protected void Button1_Click(object sender, EventArgs e)
{
if(SaveData())
{
string Script = "alert('保存成功!');location='a.aspx';"
RegisterStartupScript(Guid.NewGuid().ToString(), "<script language='javascript' type='text/javascript'>" + Script + "</script>");
}
else
{ //do what you want;}
}
前者用服务器帮你跳转,后者用用户浏览器脚本跳转
{}这个里面写了request["字段"]获取数据 你这样单纯的点击刷新当然会报错了