//this two generic methods will be put in the class file(where utilities exist)


// if the control is a postback control 

 public static void ScrollIntoView(Control controlToScroll)
    {
        Page page = HttpContext.Current.Handler as Page;
        page.RegisterStartupScript("key2", "<script> document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();</script>");
    }

// if the control is an asyncronous postback control 
    public static void ScrollIntoViewForAsync(Control controlToScroll)
    {
        Page page = HttpContext.Current.Handler as Page;
        ScriptManager.RegisterClientScriptBlock(page, typeof(page), "key2", "document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();", true);
    }
1
Contributor
0
Replies
3
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.