AutoPostBack and Focus...

P

Pai

Hello there,

I have a DropDown ListBox which is placed at the bottom of the .aspx
page, The AutoPostBack propoerty of the DropDown ListBox is set to
true.

When I change the selection of the elements in
the dropdown list box the top section of the page gets visible,
becuase the page has been posted back.

I need the focus to go to the Drop Down List Box.

I have the following code placed in the Page_Load event of the form...

this.SetFocus( this.DropDownList1 );

and the SetFocus function as follows

protected void SetFocus( System.Web.UI.Control ctrl )
{
string s = "<SCRIPT
language=\"javascript\">document.getElementById('"
+ ctrl.ID + "').focus() </SCRIPT>";

RegisterStartupScript("focus", s );

}

The focus does get set I belive to the DropDown list box, I am not
sure as when I press the tab button it goes to the next control so I
am asssuming the control has got the focus. The top section of the
page is visible, the user in such a case would be lost as to what has
happened.

I need the dropdown list box to be visible on the screen...

Thanks in advance,
Pai
 
S

susie

This line of code will help you:
-----Original Message-----
Hello there,

I have a DropDown ListBox which is placed at the bottom of the .aspx
page, The AutoPostBack propoerty of the DropDown ListBox is set to
true.

When I change the selection of the elements in
the dropdown list box the top section of the page gets visible,
becuase the page has been posted back.

I need the focus to go to the Drop Down List Box.

I have the following code placed in the Page_Load event of the form...

this.SetFocus( this.DropDownList1 );

and the SetFocus function as follows

protected void SetFocus( System.Web.UI.Control ctrl )
{
string s = "<SCRIPT
language=\"javascript\">document.getElementById('"
+ ctrl.ID + "').focus()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top