vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, January 4, 2012

Page auto scroll up or Down or focus control in asp.net


Hi..

In articles to learn how to focus any control or auto scroll to top or down pages.

Normally whn after a certain event want to focus any control we focus event. For an example if you want to focus textbox control or label.

Code should be like below…

Textbox.focus() or label.focus()

Without any event when page loads we want show a particularly a top or bottom of the page we use javascript in page laod
Event.By using script the page automatically scrolls to  particular position.

Code:

protected void Page_Load(object sender, EventArgs e)
    {
string script = "window.scrollTo(0,200);";
        ClientScript.RegisterStartupScript(this.GetType(), "scroll", script, true);
}

Suppose when page loads to show a bottom of the page we use code

string script = "window.scrollTo(0,500);";

when page loads to show a top of the page we use code

string script = "window.scrollTo(0,500);";

In window.scrollTo indiactes the (x axis, Y axis)


I hope you find and learn something usefull……….

0 comments:

Post a Comment