473,698 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't MaxLength work with multiline TextBoxes?

I have a TextBox set up as follows:

<asp:TextBox
ID="SubjectText Box"
TextMode="Multi Line"
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

Jan 1 '06
10 3661
Re:
<<... Or would the user's attempt just simply not work and cause them to see
a cryptic error message?>>

How about "none of the above"...
What you can do is write code that checks the length of the incoming value
prior to any attempt to write to the database. When it's too long you can do
whatever you want... disallow the insert/update, return a message to the
user, whatever you want to do, really. The big point here is that you don't
have to worry about what will happen. Just validate everything explicitly
before attempting to save to the database. When the validation fails, take
whatever corrective action makes sense for your scenario.

-HTH

"danthman" <da******@cox.n et> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Thanks, guys.

Okay, so tell me if I have this right...

The validation is done by the server. Users can send whatever they want
to the server by writing their own html files and loading them in their
browsers, but if I write validators to protect against all bad data,
they can't hurt me (well, not easily anyway).

I'm a littler hazier on the database issue though. If I send too much
data to the database, and it causes "buffer overflow or some other
wierd error," would this crash my server? Or would the user's attempt
just simply not work and cause them to see a cryptic error message?

I will definitely do my best to validate against all possible bad data,
but if I miss something, I hope it's at least very difficult to crash
the server. If it were just a matter of someone getting an unhandled
exception or something, I could live with that, especially if they did
something malicious to generate the exception :)

Anyway, thanks for the warning. I'll work on some stricter validators.

-Dan

Jan 2 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4031
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The problem is that only the modified data from the SingleLine TextBoxes are returned. The original data are returned for the MultiLine TextBoxes. Also, if the page is sent to the server (for validation, for instance), only the modified data for the...
1
466
by: mg | last post by:
I have a MultiLine TextBox (WebForm - C#) with the MaxLength property = 1000 but am able to type in an unlimited number of characters. Is there a way to limit the number of characters that can be typed into this TextBox?
4
8162
by: hardcoded | last post by:
I have a textbox with TextMode set to MultiLine. I also have the MaxLength set to 255. This maxlength value seems to get ignored as the user can enter unlimited characters. Does the multiline textbox not support maxlength? How can I make the work? TIA
3
5049
by: RSB | last post by:
Hi Everyone, I have this TextBox with the TextMode="MultiLine". so now it does not validate the text in the TextBox for the MaxLength SO i have decided to execute a CustomValidator for this Textbox and run a CLientSideFunction. now i was making this clientsidefunction generic so that i can validate all the other textboxes also. Now to do this i need the access to the MaxLength Property, which i am not able to read in the Java...
2
1438
by: Craig G | last post by:
how do you do it? i understand the maxlength property has no effect but is there a way around it?
6
8045
Coldfire
by: Coldfire | last post by:
I am having problems with Maxlength of Multiline "Textbox". I have browsed alot to find the solution. Tons of javascripts have been found but they all deal with <asp:textarea >............. and not <asp:TextBox >............. and some of javascripts are 1-------------------------------------------- <script language="JavaScript">
3
3133
by: gomzi | last post by:
hi, I am trying to set the maxlength property of a multiline textbox without much success. Could anyone tell me as to how it could be done ? thanks, gomzi.
3
5543
by: whitey | last post by:
this code is producing the message BUT it is entering the data. What should i do? <?php if (!$_POST) { //haven't seen the form, so show it $display_block = " <form method=\"post\" action=\"".$_SERVER."\"> <p><strong>First/Last Names:</strong><br/> <input type=\"text\" name=\"f_name\" size=\"30\" maxlength=\"75\">
15
3067
by: colyn7 | last post by:
I really can't see what's wrong in my code... the submit() onChange doesn't work.. I've tried.. <select name="ddlTestCenter" id="ddlTestCenter" style="width:180px" onChange="this.form.submit();"> it doesn't work... <input type="hidden" name="hiddenopt" value="secret"> <select name="list" onChange="document.forms.submit();">
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.