One of the basic validations that we do in our day-to-day programming is checking the length of the data. In web application, in ASP.NET we have a textbox control and there is a property called
MaxLength. The
maxLength property sets or returns the maximum number of characters in a text field. Say for example if we have set the value for the
maxlength is 20 and user is trying to enter data which is more than 20 characters then it will not allow to do the same, it works well even if user paste a text which is more than 20 characters.
There is one scenario where it fails, actually I shall not say it fails rather it is not meant for such scenario. The scenario is when we set
maxlength to 20 as shown below

And in code behind if we set text property of textbox programmatically as shown below

In this case the resulting screen would be

This means, in this case it does not restrict maximum number of characters to 20, the reason is, if you see the source of the page (the rendered HTML)

Here the
MaxLength property of asp.net control gets converted to maxlength property of HTML and this is meant for client validation and not for server validation. And we are trying to set the value at the server side, which leads to a wrong validation.
Here one has to be aware of this while using MaxLength property.Another interesting fact about the MaxLength property is, it does not work when you set TextMode="MultiLine"
Say for example we have scenario as shown below

Now if you see source of this page it will be as show below

As we know when we set
TextMode=
"MultiLine", it gets rendered as textarea and surprisingly there is no equivalent attribute/property available for textaera for
MaxLengthSo in case of
TextMode=
"MultiLine" or when we use HTML textarea we do not have any property which will restrict maxlength. In this case we can write our own javascript function which will check the length on every key press in the textarea. There are many sample available on internet for this.
Few of them are at
http://www.dynamicdrive.com/dynamicindex16/limitinput.htmhttp://www.quirksmode.org/dom/maxlength.htmlHope this information helps you.
In case if you find any information here is wrong please feel free to write to me
Bharat.Mane@gmail.comThank You
Bharat Mane
3 comments:
Making money on the internet is easy in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat seo forum[/URL], You are far from alone if you haven’t heard of it before. Blackhat marketing uses not-so-popular or not-so-known ways to produce an income online.
torby
to torebka damska , david jones torebki , torebki . david jones torebki , torebki david jones ?
[url=http://www.realcazinoz.com]Online casinos[/url], also known as familiar riches casinos or Internet casinos, are online versions of ritual ("chunk and mortar") casinos. Online casinos authorization gamblers to extemporize and wager on casino games mid-point of the Internet.
Online casinos normally forth odds and payback percentages that are comparable to land-based casinos. Some online casinos argue on higher payback percentages as a remedy in requital for concern bust-up games, and some tumble upon known payout proportion audits on their websites. Assuming that the online casino is using an fittingly programmed unpremeditatedly assorted generator, benefit games like blackjack abide an established household edge. The payout duration search of these games are established lifestyle the rules of the game.
Uncountable online casinos sublease or absorb their software from companies like Microgaming, Realtime Gaming, Playtech, Supranational Entertainment Technology and CryptoLogic Inc.
Post a Comment