Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have created a textbox Usercontrol.I do not want the textbox value which is coming from DB should be selected.Suppose my textbox value is "Admin" which is coming from database.So i want the textbox to be focused but the textbox value shouldn't be selected.Can anyone tell me how to achieve this in asp.net.
Posted
Comments
CHill60 21-Feb-15 11:53am    
"selected"? Do you mean the textbox should be read only? Why not use a label instead?
Ashad25 21-Feb-15 11:56am    
No, my textbox shouldn't be readonly, i can able to edit the textbox.For Winforms we have SelectionLength but for webforms how can we achieve this.
CHill60 21-Feb-15 12:04pm    
To be honest I have no idea what your problem is - the question is not clear
Ashad25 21-Feb-15 12:10pm    
I have a textbox with a value, so on page load the textbox value is selected by default.My requirement is on page load the textbox value shouldn't be selected in web forms not winforms
CHill60 21-Feb-15 12:16pm    
As far as I know you actually have to put code IN (javascript) to get the text autoselected, so if you don't want that behaviour take the code out

 
Share this answer
 
Comments
Kuthuparakkal 22-Feb-15 17:14pm    
my 5+
Sergey Alexandrovich Kryukov 22-Feb-15 17:21pm    
Thank you.
—SA
Mark the input field as readonly.
Then try Focusing and Selecting the Text in ASP.NET TextBox Controls[^]
 
Share this answer
 
Comments
Kuthuparakkal 22-Feb-15 17:14pm    
Good one!
Abhinav S 22-Feb-15 21:26pm    
Thanks.

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