本文介绍了为什么MaxLength不使用多行TextBoxes?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个TextBox设置如下: < asp:TextBox ID =" SubjectTextBox" TextMode =" MultiLine" MaxLength =" 100" Rows =" 2" Wrap =" true" runat =" server" /> 想法是用户获得100个字符来指定他们的主题。在 中,此TextBox的内容将被插入数据库 字段,其数据类型为VARCHAR(100)。 不幸的是,当 TextMode设置为multiline时,MaxLength属性被禁用/忽略。这不是一个正式的错误,因为它在文档中提到了 ,但它肯定是我的 opnion中的设计缺陷。 现在我必须设置一个验证器,以确保字符串不会太长,并且用户不知道他们输入的内容太多了,直到他们 点击提交并收到错误消息。我想我可以说最多100个 个字符在文本框旁边,但这会使页面混乱, ,假设用户甚至知道什么是字符。是什么,他们应该做什么?b $ b我不知道这是微软的事情还是只是限制/> html,但我希望有人能尽快修复它。 -DanI have a TextBox set up as follows:<asp:TextBoxID="SubjectTextBox"TextMode="MultiLine"MaxLength="100"Columns="50"Rows="2"Wrap="true"runat="server" />The ideas is that users get 100 characters to specify their subject. Infact, the content of this TextBox will get inserted into a databasefield whose data type is VARCHAR(100).Unfortunately, the MaxLength property gets disabled/ignored when theTextMode is set to "multiline." This isn''t officially a bug, since it''smentioned in the documentation, but it certainly is a design flaw in myopnion.Now I have to set up a validator to make sure the string isn''t toolong, and users will have no idea they have typed too much until theyhit Submit and get an error message. I suppose I could say "max of 100characters" next to the textbox, but this will clutter up the page,and, assuming users even know what a "character" is, what are theysupposed to do, count?I don''t know if this is a Microsoft thing or just a limitation withhtml, but I hope someone fixes it soon.-Dan推荐答案 嗯,告诉HTML规范设计师;-) 所有ASP.NET Web控件最终都呈现为HTML元素。不幸的是, a TextArea没有MaxLength属性... 干杯, - Joerg Jooss ne********@joergjooss.de 这篇关于为什么MaxLength不使用多行TextBoxes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 20:00