Keeping focus question

4 posts, 1 answers
  1. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 20 Apr 2009 Link to this post

    I have a FormView with a lot of TextBoxes that AutoPostBack and perform an update on the OnTextChanged event.~26nbsp~3b I~27m using the RadAjaxManager on this FormView~2c and I was wondering if there is a way to keep the focus on the current TextBox that has been clicked on or tabbed to.~26nbsp~3b That isn~27t the box firing the event~2c but the box that the user is at right when the loading message gets displayed.~3cbr /~3e
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 23 Apr 2009 Link to this post

    Hello Mike Dennis,

    You can get a reference to the text box in code behind and use the ScriptManager's SetFocus method:

    ScriptManager.GetCurrent(this.Page).SetFocus(currentTextBox); 

    I hope this helps.

    Greetings,
    Tsvetoslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 27 Apr 2009 Link to this post

    Is there a way to get what control currently has focus during the OnTextChanged event~3f~26nbsp~3b There are a lot of text boxes~2c and the user could click any of them~2c so i would need to know which control has focus so that I can use it to set focus later.~3cbr /~3e
  5. Answer
    Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 30 Apr 2009 Link to this post

    Hi Mike Dennis,

    You need to get on the client the ID of the textbox that received the focus before the postback and use it when the page loads to set the focus to this control. How exactly this should be done depends on your particular implementation.

    Please, review the attached sample for some helpful suggestions in this direction.

    Best Regards,
    Tsvetoslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top