内容简介:翻译自:https://stackoverflow.com/questions/1928651/how-do-i-limit-the-length-of-characters-in-a-textbox-in-mvc
我想在MVC中将文本框限制为10个字符.
<label ID="lbl2" runat="server" Width="20px"></label> <%=Html.TextBox("polNum") %> <label ID="lbl1" runat="server" Width="10px"></label>
我知道你可以在.net中设置Max Length属性.如何使用以这种方式生成的文本框在MVC中执行此操作?
你需要设置一些html属性……
就像是:
<%=Html.TextBox("polNum",null, new {maxlength=10}) %>
祝好运
翻译自:https://stackoverflow.com/questions/1928651/how-do-i-limit-the-length-of-characters-in-a-textbox-in-mvc
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 字符串的长度,是字符数量,还是字节数量?
- python – 可变长度的numpy recarray字符串
- C#:如何在string []中获取字符串的长度
- 查找一个字符串中最长不含重复字符的子字符串,计算该最长子字符串的长度
- mysql的length函数和char_length中文字符长度计算函数
- memcached对key和value的限制 memcached的key最大长度和Value最大长度
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Powerful
Patty McCord / Missionday / 2018-1-25
Named by The Washington Post as one of the 11 Leadership Books to Read in 2018 When it comes to recruiting, motivating, and creating great teams, Patty McCord says most companies have it all wrong. Mc......一起来看看 《Powerful》 这本书的介绍吧!