More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Sunday, 12 April 2009 4:12:47 AM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 23/11/2008(UTC)
Posts: 520

1. In your markup file (.aspx), add the Java script:
Code:
var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(beginRequest);
prm.add_endRequest(endRequest); 

function beginRequest()
{
prm._scrollPosition = null;
}
function endRequest()
{

}


2. add the following two generic methods in the class file(where utilities exist)

if the control is a postback control

Code:
    public static void ScrollIntoView(Control controlToScroll)
    {
        Page page = HttpContext.Current.Handler as Page;
        //please note that the "script" and "/script" should be the open and close tags
        page.RegisterStartupScript("key1", "script document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();/script");
    }

if the control is an asyncronous postback control
Code:
    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);
        ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "key2", "document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();", true);
    }
Sponsor
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.