How to limit the Textbox's Width????

Discussion in 'ASP .Net' started by =?Utf-8?B?Q2FsdmluIEtE?=, Mar 20, 2006.

  1. Hi everyone,
    I have a number of textboxes, lined up in a html table. I have split the
    table into different columns. The column widths are all relative, that is, %
    rather pixels or points so that it can grow / shrink.
    The textboxes are then placed into table cells and have their widths to be
    100% of the width of their container (table cells).
    Example
    <table id="Table1" width="100%" ....>
    <tr>
    <td width="20%">First Label column</td>
    <td width="15%">
    <asp:textbox id="TextBox1" Width="100%"
    Runat="Server"></asp:textbox>
    </td>
    <td width="20%">Second Label column</td>
    <td width="15%">
    <asp:textbox id="TextBox2" Width="100%"
    Runat="Server"></asp:textbox>
    </td>
    <td width="*"> </td>
    </tr>
    </table>

    When I display the text in TextBox1. If the text is long, the textbox
    automatically resizes to display whole string and pushes everything on the
    right to the right.
    I don't want this, is there a way to stop it from expanding beyond its
    allocated space?

    Any help is greatly appreciated.
    Thanks,
    Calvin
     
    =?Utf-8?B?Q2FsdmluIEtE?=, Mar 20, 2006
    #1
    1. Advertisements

  2. Calvin:

    If you use relative resizing you cannot cap the maximum width of the
    textbox. The best you can do is to optimize the display to a particular
    resolution and inform the users of your application that “it is best viewed
    with†that particular resolution. You can also have some server-side code
    that verifies the size of the data fields that will populate the textbox and
    then adjust the textbox width accordingly.
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 21, 2006
    #2
    1. Advertisements

  3. Thanks for your response Phillip. I was hoping for a more favourable solution
    but i guess we've reached its limitation.

    Cheers,
    Calvin
     
    =?Utf-8?B?Q2FsdmluIEtE?=, Mar 21, 2006
    #3
  4. =?Utf-8?B?Q2FsdmluIEtE?=

    mayur2509

    Joined:
    Apr 3, 2008
    Messages:
    1
    Likes Received:
    0
    1 Solution : - regarding controlling the size of textboxes

    Dear Friends!


    regarding controlling the size of textboxes,

    style="width:50px"

    Yes, it helped me!

    M
     
    mayur2509, Apr 3, 2008
    #4
  5. =?Utf-8?B?Q2FsdmluIEtE?=

    Sam.Nani

    Joined:
    Feb 12, 2013
    Messages:
    1
    Likes Received:
    0
    as simple as that .................
    add
    style="table-layout:fixed;"
    in the table containg this text box... it works for me.
     
    Sam.Nani, Feb 12, 2013
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.