Friday, February 9, 2007

Strange Maxlength behaviour

Hi,

Okay another interesting issue. Anyone ever wondered about the MaxLength property of a textbox in .NET.

Yeah by default, the MaxLength is 0 and 0 obviously in this case means INFINITE stating you can put any number of characters in the textbox.

Theoritically its perfect but practically speaking, it never takes characters more than 32K

WHY....??

Okay to the extent I got to know about it, here is the reason.

TEXTBOX ---------object
TEXTBOX.TEXT ----------string
STRING.LENGTH -------- integer / int32

SO basically its the limitation of String Class and its length property (which is of Int32 type)
that limits the length of a textbox to type (Int32) and hence the reason for limitation of textbox maxlength.


--Ashutosh

No comments:

Post a Comment