Click here to Skip to main content
15,868,153 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have textbox1 in that textbox i dont want to type any thing on the textbox1. in the run mode in the textbox1 only cursor want to blinks not to type anything on the particular textbox1 from the user.

please send the code.using csharp

Regards
naraisman P
Posted
Updated 11-Jul-12 0:46am
v2

If you don't want the user to enter anything, then just set the ReadOnly property to true.
 
Share this answer
 
One way to do that is making this textbox readonly.

another way to do is to add "onkeypress="return false" attribute in your control:

XML
<asp:TextBox ID="TextBox2" onkeypress="return false" runat="server"></asp:TextBox>


NOTE: This is only useful for asp.net. if it is a winform use the first method.
 
Share this answer
 
v2
Comments
Chandrashekar SK 11-Jul-12 8:01am    
This one will work :)
Rahul Rajat Singh 11-Jul-12 8:03am    
Thanks.
There is another way of making textbox readonly, see below:
ASP.NET
<asp:textbox id="TextBox2" onfocus="this.blur" runat="server"></asp:textbox>


Add onfocus="this.blur" attribute to your textbox. Hope it helps you.

Regards,
Vani Kulkarni
 
Share this answer
 
v3

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