If you use ASP.NET, you've probably encountered situations where you need to restrict the overall length of input and you've tried using the MaxLength property on the TextBox controls.
For the most part, that works. Most browsers properly restrict the length on the client side. However, some browsers do not properly restrict the entry length, some browsers have loopholes that allow overlong entry (copy/paste, etc.), and you can't forget malicious users.
So you can properly restrict the sizes using ASP.NET's validators, do the following.
Drag over a CustomValidator and point it to the TextBox you want to enforce length limits on.
Point the CustomValidator's ServerValidate function to this function...
protectedvoid TextLength_ServerValidate(object source, ServerValidateEventArgs args) { CustomValidator v = (CustomValidator)source; if (v != null) { TextBox t = (TextBox)this.FindControl(v.ControlToValidate); if (t != null && t.MaxLength > 0) { args.IsValid = args.Value.Length <= t.MaxLength; return; } } args.IsValid = true; // If custom validator wasn't set up correctly, assume valid }
Our Constitution has this particular separation of powers for one really good reason. It keeps the rights of the minority from being taken away or suppressed by the whims of the majority.
The exact same arguments were being made just over 30 years ago. Remember Loving v. Virginia?
Wow...six months of hardcore development and my current project is "done."
I'm putting "done" in quotes because we had to cut several corners to get the website to launch at the same time as the new back-end architecture, and aside from one really bad bug that I'm still trying to track down, the new build going live tonight should make things work significantly better.
Over the next week, I'll be filling in the feature gaps for what had to be delayed slightly, polishing up the features that need them, and hopefully find the database transaction issue that is affecting the first person after a process recycle.
I've put in 276 hours of work over the last three weeks. It's the worst crunch I have done since leaving Microsoft. I hope it will never happen again, but unfortunately I know better.