textbox question

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF1bA==?=, Jun 29, 2005.

  1. I have a user that when tabs to a textbox notices that the curser lines up
    with the end of the current text entry if the textbox is in the multiline
    mode. If the textbox is in the single line mode when tabing to it, the
    entire entry is highlighted. The user would like the entire text entry to be
    highlighted so they do not have to backspace and can just start typing if
    they need to change the entry. Just wondering if there is a way to set this
    up and still have the textbox in the multiline mode?
    Thanks.
    --
    Paul G
    Software engineer.
     
    =?Utf-8?B?UGF1bA==?=, Jun 29, 2005
    #1
    1. Advertising

  2. Paul:

    You can accomplish this with a little Javascript by handling the onFocus
    event for the textbox.

    Add this to your codebehind (C#):
    this.YourTextBoxName.Attributes.Add("onFocus","javascript:DoHighlight(this.value);");

    Then, in your HTML, inject the following:

    <script language="javascript">
    function DoHighlight(TextInBox)
    {
    if (TextInBox.length > 0)
    {
    document.Form1.YourTextBoxName.select();
    }
    }
    </script>



    Paul wrote:
    > I have a user that when tabs to a textbox notices that the curser lines up
    > with the end of the current text entry if the textbox is in the multiline
    > mode. If the textbox is in the single line mode when tabing to it, the
    > entire entry is highlighted. The user would like the entire text entry to be
    > highlighted so they do not have to backspace and can just start typing if
    > they need to change the entry. Just wondering if there is a way to set this
    > up and still have the textbox in the multiline mode?
    > Thanks.
     
    Elliot M. Rodriguez, Jun 29, 2005
    #2
    1. Advertising

  3. Hi thanks for the information. I will give this a try. Something like this
    might work for another problem I am working on. I have several controls and
    when the page loads I have script that puts the focus on the top control.
    The only problem is that about halfway down the page I have 2 dropdown list
    boxes and when the user makes a selection I call a stored procedure and fill
    the second dropdown box with values corresponding to that selection. The
    page reload to populate the second dropdown box but the focus jumps back up
    to the top control(since the page reloaded). In this case I would like the
    focus to stay where it is at (first dropdown box in the middle of the page)
    or go to the second dropdown box.
    Thanks again.
    --
    Paul G
    Software engineer.


    "Elliot M. Rodriguez" <"elliotrodriguez[s" wrote:

    > Paul:
    >
    > You can accomplish this with a little Javascript by handling the onFocus
    > event for the textbox.
    >
    > Add this to your codebehind (C#):
    > this.YourTextBoxName.Attributes.Add("onFocus","javascript:DoHighlight(this.value);");
    >
    > Then, in your HTML, inject the following:
    >
    > <script language="javascript">
    > function DoHighlight(TextInBox)
    > {
    > if (TextInBox.length > 0)
    > {
    > document.Form1.YourTextBoxName.select();
    > }
    > }
    > </script>
    >
    >
    >
    > Paul wrote:
    > > I have a user that when tabs to a textbox notices that the curser lines up
    > > with the end of the current text entry if the textbox is in the multiline
    > > mode. If the textbox is in the single line mode when tabing to it, the
    > > entire entry is highlighted. The user would like the entire text entry to be
    > > highlighted so they do not have to backspace and can just start typing if
    > > they need to change the entry. Just wondering if there is a way to set this
    > > up and still have the textbox in the multiline mode?
    > > Thanks.

    >
     
    =?Utf-8?B?UGF1bA==?=, Jun 29, 2005
    #3
    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. S. Justin Gengo
    Replies:
    0
    Views:
    564
    S. Justin Gengo
    Jul 16, 2003
  2. Hazzard
    Replies:
    2
    Views:
    576
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  3. Natty Gur
    Replies:
    0
    Views:
    491
    Natty Gur
    Jul 22, 2003
  4. =?Utf-8?B?Q2hyaXM=?=
    Replies:
    3
    Views:
    13,896
    Peter Blum
    Mar 30, 2005
  5. Jay

    Rich TextBox / HTML TextBox

    Jay, Apr 28, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    15,739
    Steve C. Orr [MVP, MCSD]
    Apr 29, 2005
Loading...

Share This Page