ASP.net Postback - Scroll to Specific Position

后端 未结 9 1024
天命终不由人
天命终不由人 2020-12-15 16:50

I have an ASP.net WebForms page that has a lot of content on the top of the screen. It has a link button that will post back to the page and show another section of the page

9条回答
  •  感情败类
    2020-12-15 17:27

    try this

    protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) {
                string targetId = Page.Request.Params.Get("__EVENTTARGET");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "focusthis", "document.getElementById('" + targetId + "').focus()", true);
    
            }
        }
    

提交回复
热议问题