User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 397,336 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,929 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Feb 4th, 2008
Views: 1,207
Set page's scroll position programmatically according to server side processing
Last edited : Feb 4th, 2008.
csharp Syntax
  1. //this two generic methods will be put in the class file(where utilities exist)
  2.  
  3.  
  4. // if the control is a postback control
  5.  
  6. public static void ScrollIntoView(Control controlToScroll)
  7. {
  8. Page page = HttpContext.Current.Handler as Page;
  9. page.RegisterStartupScript("key2", "<script> document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();</script>");
  10. }
  11.  
  12. // if the control is an asyncronous postback control
  13. public static void ScrollIntoViewForAsync(Control controlToScroll)
  14. {
  15. Page page = HttpContext.Current.Handler as Page;
  16. ScriptManager.RegisterClientScriptBlock(page, typeof(page), "key2", "document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();", true);
  17. }
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 8:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC