fitting label dimensions to length of string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    fitting label dimensions to length of string

    I have a method that is returning a string which can be of any length.
    Once this string is returned I want to display it on screen in a label
    control. How can I make the label control's height and width be
    flexible so that it always fits the length of the string it contains?

    <asp:Label ID="lblSQL" runat="server" Height="600" Width="600"
    BackColor="blue " ForeColor="whit e" Font-Names="Verdana"
    Font-Size="Small"></asp:Label>

    protected void Page_Load(objec t sender, EventArgs e)
    {
    ViewState["CountGUID"] = Request.QuerySt ring["GUID"];

    string strCountSQL =
    GetCountSql(Vie wState["CountGUID"].ToString());

    lblSQL.Text = strCountSQL;
    }




    *** Sent via Developersdex http://www.developersdex.com ***
  • Patrice

    #2
    Re: fitting label dimensions to length of string

    Just suppress the heigh and width attributes. An HTML document is rendered
    so that each element are sized to fit their content....



    "Mike P" <mike.parr@gmai l.coma écrit dans le message de groupe de
    discussion : uP3TmenRJHA.117 2@TK2MSFTNGP03. phx.gbl...
    I have a method that is returning a string which can be of any length.
    Once this string is returned I want to display it on screen in a label
    control. How can I make the label control's height and width be
    flexible so that it always fits the length of the string it contains?
    >
    <asp:Label ID="lblSQL" runat="server" Height="600" Width="600"
    BackColor="blue " ForeColor="whit e" Font-Names="Verdana"
    Font-Size="Small"></asp:Label>
    >
    protected void Page_Load(objec t sender, EventArgs e)
    {
    ViewState["CountGUID"] = Request.QuerySt ring["GUID"];
    >
    string strCountSQL =
    GetCountSql(Vie wState["CountGUID"].ToString());
    >
    lblSQL.Text = strCountSQL;
    }
    >
    >
    >
    >
    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    Working...