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. Advertising

  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.


    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Calvin KD" wrote:

    > 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?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 21, 2006
    #2
    1. Advertising

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

    Cheers,
    Calvin

    "Phillip Williams" wrote:

    > 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.
    >
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Calvin KD" wrote:
    >
    > > 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 21, 2006
    #3
  4. =?Utf-8?B?Q2FsdmluIEtE?=

    mayur2509

    Joined:
    Apr 3, 2008
    Messages:
    1
    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
    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. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    744
    Bruce Barker
    Oct 10, 2005
  2. graphicsxp

    limit colunm width in gridview

    graphicsxp, May 23, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,218
    Flinky Wisty Pomm
    May 23, 2006
  3. Replies:
    10
    Views:
    3,964
    Jukka K. Korpela
    Jan 18, 2007
  4. Replies:
    1
    Views:
    1,069
    Victor Bazarov
    Jun 28, 2005
  5. Jeff
    Replies:
    1
    Views:
    398
    Nathan Sokalski
    Oct 8, 2008
Loading...

Share This Page