为什么MaxLength不使用多行TextBoxes? [英] Why doesn't MaxLength work with multiline TextBoxes?

查看:69
本文介绍了为什么MaxLength不使用多行TextBoxes?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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,但我希望有人能尽快修复它。


-Dan

I have a TextBox set up as follows:

<asp:TextBox
ID="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. In
fact, the content of this TextBox will get inserted into a database
field whose data type is VARCHAR(100).

Unfortunately, the MaxLength property gets disabled/ignored when the
TextMode is set to "multiline." This isn''t officially a bug, since it''s
mentioned in the documentation, but it certainly is a design flaw in my
opnion.

Now I have to set up a validator to make sure the string isn''t too
long, and users will have no idea they have typed too much until they
hit Submit and get an error message. I suppose I could say "max of 100
characters" next to the textbox, but this will clutter up the page,
and, assuming users even know what a "character" is, what are they
supposed to do, count?

I don''t know if this is a Microsoft thing or just a limitation with
html, but I hope someone fixes it soon.

-Dan

推荐答案

Hello danthman,
Hello danthman,
我有一个TextBox设置如下:

< asp:TextBox
ID =" SubjectTextBox"
TextMode =" MultiLine"
MaxLength =" 100"
Columns =" 50"
Rows =" 2"
Wrap =" true"
runat =" server" />
想法是用户得到100个字符来指定他们的主题。
实际上,这个TextBox的内容将被插入数据库
字段,其数据类型为VARCHAR(100不幸的是,当
TextMode设置为multiline时,MaxLength属性被禁用/忽略。这不是一个正式的错误,因为
它在文档中提到,但它确实是我的意见中的设计缺陷。
I have a TextBox set up as follows:

<asp:TextBox
ID="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.
In fact, the content of this TextBox will get inserted into a database
field whose data type is VARCHAR(100).

Unfortunately, the MaxLength property gets disabled/ignored when the
TextMode is set to "multiline." This isn''t officially a bug, since
it''s mentioned in the documentation, but it certainly is a design flaw
in my opnion.




嗯,告诉HTML规范设计师;-)

所有ASP.NET Web控件最终都呈现为HTML元素。不幸的是,

a TextArea没有MaxLength属性...


干杯,

-

Joerg Jooss
ne********@joergjooss.de


一行的ASP.NET TextBox呈现为HTML< INPUT type =" Text">

元素,而带有TextBox的文本框多行呈现为HTML< TextArea>

元素,根据HTML规范没有MaxLength属性。这个

并不是微软整理的规范。这就是我们从可爱的标准委员会那里得到的。


几个解决方法:
http://www.dynamicdrive.com/dynamici.../maxlength.htm

http://www.siteexperts.com/ie5/ htc / ts08 / page1.asp


另一个解决方法是使用验证器及其问题,因为你已经明显意识到了b $ b。 />

-Jeff


" danthman" <哒****** @ cox.net>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
The ASP.NET TextBox of one line renders as an HTML <INPUT type="Text"... >
element, whereas a TextBox with multiple lines renders as an HTML <TextArea>
element, which has no MaxLength property per the HTML specification. This
isn''t a specification that Microsoft put together. This is what we got from
the lovely standards commmittee.

A couple of workarounds:
http://www.dynamicdrive.com/dynamici.../maxlength.htm

http://www.siteexperts.com/ie5/htc/ts08/page1.asp

Another workaround is to use a validator with its problems as you are
already apparently aware.

-Jeff

"danthman" <da******@cox.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
我有一个TextBox设置如下:

< asp:TextBox
ID =" SubjectTextBox"
TextMode =" MultiLine"
MaxLength =" 100"
Columns =" 50"
Rows =" 2"
Wrap =" true"
runat =" server" />

想法是用户获得100个字符来指定他们的主题。事实上,这个TextBox的内容将被插入到数据类型为VARCHAR(100)的数据库中。

不幸的是,当MaxLength属性被禁用/忽略时
TextMode设置为multiline。这不是一个正式的错误,因为它在文档中提到了,但它确实是我的
opnion的设计缺陷。

现在我必须设置一个验证器,以确保字符串不长,用户将不知道他们输入太多,直到他们点击提交并收到错误消息。我想我可以说最多100个字符在文本框旁边,但这会使页面混乱,并且假设用户甚至知道什么是字符。是什么,他们应该做什么,算什么?

我不知道这是微软的东西,还是仅仅是对HTML的限制,但我希望有人很快就修好了。

-Dan
I have a TextBox set up as follows:

<asp:TextBox
ID="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. In
fact, the content of this TextBox will get inserted into a database
field whose data type is VARCHAR(100).

Unfortunately, the MaxLength property gets disabled/ignored when the
TextMode is set to "multiline." This isn''t officially a bug, since it''s
mentioned in the documentation, but it certainly is a design flaw in my
opnion.

Now I have to set up a validator to make sure the string isn''t too
long, and users will have no idea they have typed too much until they
hit Submit and get an error message. I suppose I could say "max of 100
characters" next to the textbox, but this will clutter up the page,
and, assuming users even know what a "character" is, what are they
supposed to do, count?

I don''t know if this is a Microsoft thing or just a limitation with
html, but I hope someone fixes it soon.

-Dan



然而,MS可能会发出限制所需的JavaScript

个字符数。你可以做到这一点,但它需要JavaScript来计算每个击键次数的字符数。


" Jeff" < A@B.COM>在消息中写道

news:e6 ************** @ tk2msftngp13.phx.gbl ...
MS could have, however, emitted the JavaScript necessary to restrict the
number of characters. You can do that, but it requires JavaScript to count
the number of characters with each key stroke.

"Jeff" <A@B.COM> wrote in message
news:e6**************@tk2msftngp13.phx.gbl...
ASP.NET TextBox一行呈现为HTML< INPUT type =" Text">
元素,而具有多行的TextBox呈现为HTML
< TextArea> element,根据HTML
规范没有MaxLength属性。这不是微软整理的规范。
这是我们从可爱的标准委员会那里得到的。

有几个解决方法:
http://www.dynamicdrive.com/dynamici.../maxlength.htm
http://www.siteexperts.com /ie5/htc/ts08/page1.asp

另一种解决方法是使用验证器及其问题,因为您已经明显知道了。
-Jeff


" danthman" <哒****** @ cox.net>在消息中写道
新闻:11 ********************** @ f14g2000cwb.googlegr oups.com ...
The ASP.NET TextBox of one line renders as an HTML <INPUT type="Text"... >
element, whereas a TextBox with multiple lines renders as an HTML
<TextArea> element, which has no MaxLength property per the HTML
specification. This isn''t a specification that Microsoft put together.
This is what we got from the lovely standards commmittee.

A couple of workarounds:
http://www.dynamicdrive.com/dynamici.../maxlength.htm

http://www.siteexperts.com/ie5/htc/ts08/page1.asp

Another workaround is to use a validator with its problems as you are
already apparently aware.

-Jeff

"danthman" <da******@cox.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
我有一个TextBox设置如下:

< asp:TextBox
ID =" SubjectTextBox"
TextMode =" MultiLine"
MaxLength =" 100"
Columns =" 50"
Rows =" 2"
Wrap =" true"
runat =" server" />

想法是用户获得100个字符来指定他们的主题。事实上,这个TextBox的内容将被插入到数据类型为VARCHAR(100)的数据库中。

不幸的是,当MaxLength属性被禁用/忽略时
TextMode设置为multiline。这不是一个正式的错误,因为它在文档中提到了,但它确实是我的
opnion的设计缺陷。

现在我必须设置一个验证器,以确保字符串不长,用户将不知道他们输入太多,直到他们点击提交并收到错误消息。我想我可以说最多100个字符在文本框旁边,但这会使页面混乱,并且假设用户甚至知道什么是字符。是什么,他们应该做什么,算什么?

我不知道这是微软的东西,还是仅仅是对HTML的限制,但我希望有人很快修好了。

-Dan
I have a TextBox set up as follows:

<asp:TextBox
ID="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. In
fact, the content of this TextBox will get inserted into a database
field whose data type is VARCHAR(100).

Unfortunately, the MaxLength property gets disabled/ignored when the
TextMode is set to "multiline." This isn''t officially a bug, since it''s
mentioned in the documentation, but it certainly is a design flaw in my
opnion.

Now I have to set up a validator to make sure the string isn''t too
long, and users will have no idea they have typed too much until they
hit Submit and get an error message. I suppose I could say "max of 100
characters" next to the textbox, but this will clutter up the page,
and, assuming users even know what a "character" is, what are they
supposed to do, count?

I don''t know if this is a Microsoft thing or just a limitation with
html, but I hope someone fixes it soon.

-Dan




这篇关于为什么MaxLength不使用多行TextBoxes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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