As you know it is very easy to scroll a page in ASP.Net, by defining an anchor tag you can do this but in this article I am going to explain for you how to a scroll page from server side with the help of JavaScript method scrollIntoView.
For that you have to write JavaScript like the following in code behind. Here I have defined one method in code behind.
In the above method I have registered the script for setting the Scroll and Focus.
After that I have called the defined method in the Page Load like that.
Code
if (!Page.IsStartupScriptRegistered("setScrollAndFocus")){ ScrollToMyFavouriteControl(TextBoxMyFavourite);}
Since I got one comment for this article, Yes it is true that RegisterStartupScript is obsolete in higher .Net framework versions, so what is the alternative.
You can replace RegisterStartupScript with ClientScript.RegisterStartupScript like this.
As per your suggestion, I have modified the article.
V
VesteditedPosted Dec 16, 2010, 9:36 PM ESTEdited Dec 16, 2010, 9:36 PM EST
Thank you for your article. However, I think that you should modify it a bit, because you use the deprecated method: http://msdn.microsoft.com/en-us/library/system.web.ui.page.registerstartupscript.aspx
Jake KoornhofPosted Jun 23, 2011, 4:32 AM EDT
Thank you , this works excellent, just what I was looking for
Blocked AccountPosted Dec 20, 2010, 9:07 PM EST
As per your suggestion, I have modified the article.
VesteditedPosted Dec 16, 2010, 9:36 PM ESTEdited Dec 16, 2010, 9:36 PM EST
Thank you for your article. However, I think that you should modify it a bit, because you use the deprecated method: http://msdn.microsoft.com/en-us/library/system.web.ui.page.registerstartupscript.aspx