aspx中页面按钮写返回上一页代码

Cherise ·
更新时间:2024-09-21
· 520 次阅读

<script>history.go(-1);</script>
不管怎样,它就是不返回上一页。
经查资料,原来在asp.net的处理方式已经有所改变。当用户点击按钮时,页已经刷新了。因此我们需要把-1改为-2方可以返回至前一页。
代码如下:
protected void ButtonGoBack_Click(object sender, EventArgs e)
{
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script>history.go(-2);</script>");
}

示例运行效果:



返回上一页 aspx 按钮

需要 登录 后方可回复, 如果你还没有账号请 注册新账号