Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I reached the textbox it should be highlighted automatically
Posted
Comments
Anuja Pawar Indore 6-Dec-11 4:36am    
What do you mean by reach? Mean key press or the tab press event ? How will you reach the text box.
sriman.ch 6-Dec-11 4:41am    
You mean when cursor reaches your textbox its text should be highlighted or what ? Be more specific...

This might be a solution to u r problem:
check this

Change Textbox/Input background color on focus[^]
 
Share this answer
 
Use client-side script instead, see this link, it has the codes.

http://www.roseindia.net/tutorial/jquery/inputRowHiglighting.html[^]

Regards,
Eduard
 
Share this answer
 
Comments
Member 8131879[Sneha K] 31-May-12 8:40am    
Hello,
Want to hoghlight text in textbox.But not first letter.Using this
textbox.SelectionStart = 0;
textbox.SelectionLength = textbox.Text.Length;
if (sender is TextBox)
{
int a = 1;
if(textBox1.SelectionLength>1)
(sender as TextBox).SelectionLength.ToString();
}
highlight 1st letter.but,want to highlight all ;etters after 1st letter.Example: suppose i want name as "car".When i type 1st letter "c" then this letter not ale to get highlight.after "C" when i type "a"letter then this should be get hilight and so on.how to do it?
Member 8131879[Sneha K] 1-Jun-12 0:24am    
Hello,

As per given solution by you i.e

textBox1.SelectionStart = 1;
textBox1.SelectionLength = textBox1.Text.Length - 1;

Ican select the second letter.but,wheni type 3rd letter that time 2nd letter get repalce by 3rd letter.I don't want like that.When i press right key then only can able to type 3rd letter.otherwaise evetytime 2nd postion get replace by new letter.

Example: Suppose i want the word "Hello" .When i type "H" then as per above code "H" not get selected.then i type "e" its get selected.next when i type "l" it get replace by character "e"so everytime in my textbox 2nd position letter get replace.when i press righkey that time only can add letter on 3rd position and so on.

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