Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to select a particular text(word) in ASP:Textbox(multi-line) as I have starting index and Last index of the word on click of event I want that word to be get selected in that multiline text box I want to write code on server side.Please tell me C# code not JavaScript.

Thanks in advance
Posted
Updated 12-Apr-11 23:34pm
v2
Comments
Pong D. Panda 13-Apr-11 0:19am    
You want the text on your multi line highlighted through your code behind? If you want a code to select a text within a given start and end location, use Substring(index, length).
Uday Kumar B R 13-Apr-11 0:28am    
hi,
The Substring will just return that Substring this wont highlight that word in a Textbox

The Substring will just return that Substring this wont highlight that word in a Textbox

AFAIK, you can't do this in asp:TextBox control.
You will need to use RichTextBox[^].

I used http://freetextbox.com/[^] sometime back in one of my sample project. This will also do what you require. Take a look. :thumbsup:
 
Share this answer
 
v2
document.getElementById('ASP_CONTROL_ID_HERE').select();
 
Share this answer
 
v2
Comments
Toniyo Jackson 13-Apr-11 5:14am    
Added pre tag
Uday Kumar B R 26-Apr-11 23:28pm    
This will select all the text in multiline textbox.I want to select perticular word.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900