Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Selecting text in a textbox

Reply
Thread Tools

Selecting text in a textbox

 
 
JJ
Guest
Posts: n/a
 
      06-12-2007
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


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      06-12-2007
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
>



 
Reply With Quote
 
 
 
 
Omar Abid
Guest
Posts: n/a
 
      06-12-2007
On 12 juin, 12:40, "JJ" <a...@xyz.com> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting text after TextBox.Focus() is executed David C ASP .Net 1 09-13-2007 10:41 AM
Textbox, Input (text) on turbotax... anyone know which 3rd party textbox this is??? pld888@gmail.com ASP .Net 3 02-23-2007 08:51 PM
ASP.NET textbox loses text value in composite control but Textbox subclass doesn't!? ErwinP ASP .Net Web Controls 1 08-19-2005 01:50 PM
writing two textbox's text in one textbox agb ASP .Net Web Controls 1 08-27-2003 12:57 AM
Selecting all text in a textbox? Harry Simpson ASP .Net 3 07-28-2003 04:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57