Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maxlength Property

Status
Not open for further replies.

PBS2

Programmer
May 17, 2004
43
GB
I have a singleline textbox in which I want to restrict the entry to 11 characters. I have tried setting the MaxLength prperty of the textbox to 11. However, when I do this I cannot enter more than 3 characters into the textbox??

Can anyone tell me why this might be please.
 
thats strange, can u do a view source and see what HTML output is generated for the textbox???

Known is handfull, Unknown is worldfull
 
This is the HTML for the text box:-

<TD style="WIDTH: 161px"><asp:textbox id="txtSMSUsername" runat="server" CssClass="StdTextBox" MaxLength="11"></asp:textbox></TD>

Does this give you any clues?
 
what about the HTML that it is outputting (ie in the browser???)

Known is handfull, Unknown is worldfull
 
Sorry vbkris I am new to asp.net so am not sure how to check the HTML output in the browser. How do I check this for you?
 
in the browser do a right click, a "View source" options must be there (IE)...

Known is handfull, Unknown is worldfull
 

I have now fixed the problem with Maxlength - I was populating the textbox with the value from a table including trailing spaces. Consequently the trailing spaces were included in the Maxlength calculation. So when I tried to amend a 3 character Username to make it longer it would not let me because it thought it was already 11 characters (as it had included the trailing spaces). So I now Trim the value taken from the table. Sorry to waste your time.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top