验证文本框以供用户使用 [英] validating textbox for user purpose

查看:84
本文介绍了验证文本框以供用户使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在那个textbox中有textbox1,我不想在textbox1上键入任何东西.在textbox1的运行模式下,仅光标要闪烁,不要在用户的特定textbox1上键入任何内容.

请发送代码.使用csharp

问候
naraisman P

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

推荐答案

如果您不希望用户输入任何内容,则只需将ReadOnly属性设置为true.
If you don''t want the user to enter anything, then just set the ReadOnly property to true.


一种做到这一点的方法就是制作这个textbox readonly.

另一种方法是在控件中添加"onkeypress="return false"属性:

One way to do that is making this textbox readonly.

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

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



注意:这仅对asp.net有用.如果它是Winform,则使用第一种方法.



NOTE: This is only useful for asp.net. if it is a winform use the first method.


还有另一种方法使文本框变为只读,请参见下文:
There is another way of making textbox readonly, see below:
<asp:textbox id="TextBox2" onfocus="this.blur" runat="server"></asp:textbox>



onfocus="this.blur"属性添加到您的文本框.希望对您有帮助.

此致
瓦尼·库尔卡尼(Vani Kulkarni)



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

Regards,
Vani Kulkarni


这篇关于验证文本框以供用户使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆