Controls that have a Label property

3 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 09 Nov 2010 Link to this post

    When these controls render they do so in a table, label in one cell and control in another.

    No problems so far.

    However, if you've lots of these controls and the labels are all different lengths then you have the devils own job of getting your controls to stack nicely.

    It would be nice if these controls rendered a class name in the <TD> tag (or better yet, had a LabelCssClass property where the <TD> and LabellCssClass property value could be used to write a CSS rule) so that the width could be set to a consistent value so that all the controls stacked neatly.

    --
    Stuart 
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 09 Nov 2010 Link to this post

    Hi Stuart,

    You can use the following approach:

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <head runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
    <style type="text/css">
     
    .myLabel
    {
        display:block;
        width:120px;
        margin-right:0 !important;
        padding-right:0 !important;
    }
     
    .RadComboBox .myLabel
    {
        float:left;
    }
     
    </style>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
     
    <telerik:RadTextBox ID="RadTextBox2" runat="server" Label="Label 1" LabelCssClass="myLabel" Width="300px" />
    <br /><br />
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Label="Longer Label 2" LabelCssClass="myLabel" Width="300px" />
    <br /><br />
    <telerik:RadComboBox ID="RadComboBox1" runat="server" Label="Even Longer Label 3" LabelCssClass="myLabel" Width="180px" />
     
    <div style="clear:both"><!-- --></div>
     
    following content
     
    </form>
    </body>
    </html>


    Sincerely yours,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 10 Nov 2010 Link to this post

    Now I feel really silly!

    How did I manage to miss that in the docs.

    <sigh/> 

    I really shouldn't be allowed to work unsupervised.

    -- 
    Stuart
Back to Top