Results 1 to 3 of 3

Thread: Shift/set focus on textboxes in ASP.NET

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Posts
    16

    Shift/set focus on textboxes in ASP.NET

    Hi,

    I have a webform in which the user is required to input his tel. no. Now when the user enters the area code i would like the focus to shift to the tel. no. textbox. Is there any way cursor focus can be shifted from one textbox to another in ASP.NET pages.

    Also is it possible to format the way the tel. no. textbox is displayed like for ex. XXX-XXXX (with the dash in the middle).

    Thanks in advance for the help.
    All your distributed computing needs are belong to us!

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Yes... use javascript. Control focus on the client side has nothing to do with ASP.NET, because ASP.NET is not a client-side technology, its a server-side technology.

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    So... its like this...

    If you have two textboxes on a web page....

    In the VB code-behind, you simply add an attribute called 'onBlur' to the first textbox.

    VB Code:
    1. Private Sub Page_Load
    2.  Me.TextBox1.Attributes.Add("onBlur","document.getElementById('TextBox2').focus();")
    3. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width