473,756 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting text in a textbox

JJ
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 programmaticall y?

Thanks,

JJ
Jun 12 '07 #1
2 2362
On 12 juin, 12:40, "JJ" <a...@xyz.comwr ote:
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 programmaticall y?

Thanks,

JJ
It's possible use :
textbox.select( )
Omar Abid

Jun 12 '07 #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" <ab*@xyz.comwro te in message
news:u9******** ******@TK2MSFTN GP04.phx.gbl...
>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 programmaticall y?

Thanks,

JJ

Jun 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1378
by: DOTNETGUY | last post by:
What i am doing is pretty simple. I am writing a simple control that you probably have seen on many websites. You have a phone number field ( 3 Textboxes ) if the size of the textbox text is = 3 move to the second text box. My problem is: How do i tell my app to select the second text box? Here is an example on what I have so far: Private Sub txtPhone1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
4
3163
by: melanieab | last post by:
Hi, I need to write something so that when a textbox is entered (this is for a touchscreen), all the text in that textbox is selected (highlighted) and new keystrokes replace the old text. Help! Thanks (again), Melanie
3
24272
by: Harry Simpson | last post by:
I've got a server-side textbox that receives the focus when the page loads. It has the text "Refine your Search" in the textbox. Obviously the user needs to highlight the "Refine your Search" section to replace this with thier text. I've googled and found javascript (which doesn't seem to work with the server side control). Is there a way to do this with ASPNET??
3
1408
by: Strange Cat | last post by:
Hi everyone Is it possible to select the contents in an aspnet textbox? (Like the old textbox selectstart and so on properties) Thanx in advance
5
7315
by: marfi95 | last post by:
I'm very confused. I'm trying to automatically select the text when my textbox gets the focus. This is typically when the user has clicked the mouse in the field. This is the code I have in the Text1_GotFocus event: Text1.SelectionStart = 0 Text1.SelectionLength = Text1.Text.Length However, the text does not get highlighted. It appears to be the
4
1377
by: rcoco | last post by:
I want to select one Row from a datagrid so I create a textBbox(txtname) and Button for the user to write the name in textBox and By the click of the button it select the corresponding row. But it's not selecting the row neighther I'm getting any mistake message I'm I missng some thing? I wrote the code on Button_Click sqlCommand as follows: SqlCommand myCommand = new SqlCommand("SELECT * from employee where fullname Like %+txtname+%"...
2
4538
by: Abubakar | last post by:
Hi, In a normal Windows.Forms.TextBox control, I want to be able to select a text (ie highlight, this is by default possible) and than be able to drag that text through my mouse pointer to another textbox, or any control, than drop it. How do v do this? Regards, ...ab
1
2196
by: David C | last post by:
I see that the .Focus() method is new in .NET 2.0, which I think is handy. But is there a way to make text in a textbox selected when the focus is set in it? This would be equivalent to calling .select() in javascript.
3
1910
by: Shawn | last post by:
I'm trying to go through a large number of logically named textboxes using a loop and cannot figure out how short of explicitly referencing every single one.
0
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6514
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.