• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

文本框只允许字母.......在C#文本显示代码只允许在C#使用相同的字母数字

用户头像
it1352
帮助1

问题说明

文本框只允许字母.......显示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

正确答案

#1
谷歌是你的朋友。例如,参见 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[^]

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfjjff
系列文章
更多 icon
同类精品
更多 icon
继续加载