AutoPostBack and Focus...

Discussion in 'ASP .Net Web Controls' started by Pai, Nov 12, 2003.

  1. Pai

    Pai Guest

    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
    Pai, Nov 12, 2003
    #1
    1. Advertising

  2. Pai

    susie Guest

    This line of code will help you:
    <%@ Page Language="VB" SmartNavigation="true"%>

    >-----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()

    </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
    >.
    >
    susie, Nov 14, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr
    Replies:
    2
    Views:
    5,268
    Mad Scientist Jr
    Jun 29, 2004
  2. - Steve -

    AutoPostBack on TextBox loses Focus

    - Steve -, Jun 29, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,531
    - Steve -
    Jun 29, 2004
  3. Replies:
    1
    Views:
    2,069
    =?Utf-8?B?QmVudCBLcmlzdGlhbnNlbg==?=
    Jun 21, 2006
  4. Asp.Net AutoPostback and control focus

    , Jun 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    114
    Nathan Sokalski
    Jun 23, 2006
  5. Roger
    Replies:
    3
    Views:
    311
Loading...

Share This Page