文本框只允许字母.......在C#文本中显示代码只允许在C#中使用相同的字母数字 [英] Textbox only allow letter....... Show the code in C# text only allow alphanumeric same in C#

查看:75
本文介绍了文本框只允许字母.......在C#文本中显示代码只允许在C#中使用相同的字母数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文本框只允许字母.......显示c中的代码

文本只允许在c#中使用相同的字母数字



我尝试了什么:



告诉我c#asp.net中的代码

textbox only allow letter....... show the code in c#
text only allow alphanumeric same in c#

What I have tried:

just tell me the code in c#asp.net

推荐答案

谷歌是你的朋友。例如,参见 c# - 如何制作一个文本框只接受号码? - 堆栈溢出 [ ^ ]。虽然不能完全解决您的问题,但第一个答案说明了该技术。
Google is your friend. See for instance c# - How do I make a textbox that only accepts numbers? - Stack Overflow[^]. While not exactly solving your problem, the first answer illustrates the technique.


对于ASP.NET,您不希望在C#中执行此操作 - 您希望在JavaScript中执行此操作,以便用户无法输入不良信息。在C#中执行此操作意味着在用户完成整个表单或每个字符时往返服务器。前者对于用户来说是一种痛苦,因为他们最后被告知这是错误的并且必须回去修复它,后者是缓慢而笨拙的。使用JS意味着它在客户端完成,服务器不参与。

Javascript验证:使用JavaScript验证TextBox [ ^ ]
For ASP.NET you don't want to do it in C# - you want to do it in JavaScript so that the user can't enter "bad" info. Doing it in C# means a round trip to the server either when the user is finished with the whole form, or for each character. The former is a pain for the user as they get told at the end "that was wrong" and have to go back to fix it, the latter is slow and awkward. Using JS means it's done at the client end and the server isn't involved.
Javascript validation: Validate TextBox using JavaScript[^]


这篇关于文本框只允许字母.......在C#文本中显示代码只允许在C#中使用相同的字母数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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