您的位置:首页 > 其它

点击按钮刷新页面定位到当时的位置

2016-03-25 09:20 218 查看
方法一

前台: 

<a id="s1" name="s1"></a>

后台:

ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('成功!');location.href='AAA.aspx#s1'", true);

方法二

如果锚点不好用,可以使用 TextBox1.Focus();

点某按钮的时候:

ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('成功!');location.href='AAAA.aspx?no=1';", true);

在 !IsPostBack里:

 string no = Request.QueryString["no"];

            if (no == "1")

            {

                TextBox1.Focus();

            }

然后把这个TextBox1放在合适的位置,并把width设为0,BorderStyle设为:None,就看不见它了,还能跳转到合适的位置。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: