How to set width of textbox to be same as MaxLength in ASP.NET

Posted by John Galt on Stack Overflow See other posts from Stack Overflow or by John Galt
Published on 2010-06-10T22:34:24Z Indexed on 2010/06/11 1:13 UTC
Read the original article Hit count: 303

Filed under:
|
|
|
|

Is there a way I can limit the width of a textbox to be equal to the MaxLength property? In my case right now, the textbox control is placed in a table cell as in this snippet:

<td class=TDSmallerBold style="width:90%">
        <asp:textbox id="txtTitle" runat="server"
            CausesValidation="true"
            Text="Type a title here..be concise but descriptive. Include price."
            ToolTip="Describe the item with a short pithy title (most important keywords first). Include the price. The title you provide here will be the primary text found by search engines that index Zipeee content." 
            MaxLength="60"
            Width="100%">
        </asp:textbox>

(I know I should not use HTML tables to control layout..another subject for sure) but is there a way to constrain the actual width to the max number of characters allowed in the typed box?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about textbox