Selecting text in a textbox

Discussion in 'ASP .Net' started by JJ, Jun 12, 2007.

  1. JJ

    JJ Guest

    I have a textbox that is used to insert some html code. I want to highlight
    errors in the code, possibly by selecting the text.

    Is it possible to highlight/select areas of a textbox programmatically?

    Thanks,

    JJ
     
    JJ, Jun 12, 2007
    #1
    1. Advertising

  2. You can select only one block of text in a web page, as the web page has
    only one selection object, regardless of the browser. So, yes, you can
    select text in a textbox using JavaScript. It's not easy, but it can be
    done. How it is done depends on the client browser, as IE and Mozilla have
    different implementations of the selection object and the range ("TextRange"
    in IE) object.

    Here are a couple of articles that deal with the subject with IE and FireFox
    respectively:

    http://www.bazon.net/mishoo/articles.epl?art_id=1292
    http://www.dotvoid.com/view.php?id=11

    --
    HTH,

    Kevin Spencer
    Microsoft MVP

    Printing Components, Email Components,
    FTP Client Classes, Enhanced Data Controls, much more.
    DSI PrintManager, Miradyne Component Libraries:
    http://www.miradyne.net

    "JJ" <> wrote in message
    news:...
    >I have a textbox that is used to insert some html code. I want to highlight
    >errors in the code, possibly by selecting the text.
    >
    > Is it possible to highlight/select areas of a textbox programmatically?
    >
    > Thanks,
    >
    > JJ
    >
     
    Kevin Spencer, Jun 12, 2007
    #2
    1. Advertising

  3. JJ

    Omar Abid Guest

    On 12 juin, 12:40, "JJ" <> wrote:
    > I have a textbox that is used to insert some html code. I want to highlight
    > errors in the code, possibly by selecting the text.
    >
    > Is it possible to highlight/select areas of a textbox programmatically?
    >
    > Thanks,
    >
    > JJ


    It's possible use :
    textbox.select()
    Omar Abid
     
    Omar Abid, Jun 12, 2007
    #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. Harry Simpson

    Selecting all text in a textbox?

    Harry Simpson, Jul 28, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    522
    Marc Hoeppner
    Jul 28, 2003
  2. Strange Cat

    Selecting textbox contents

    Strange Cat, Feb 23, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    698
    Malek
    Feb 23, 2004
  3. Replies:
    3
    Views:
    751
    George Ter-Saakov
    Feb 23, 2007
  4. David C
    Replies:
    1
    Views:
    373
    Kevin Spencer
    Sep 13, 2007
  5. agb

    writing two textbox's text in one textbox

    agb, Aug 26, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    173
    Ken Cox [Microsoft MVP]
    Aug 27, 2003
Loading...

Share This Page