This is a migrated thread and some comments may be shown as answers.

Use label css on custom label

3 Answers 511 Views
Input
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 08 Dec 2011, 12:29 PM
Hi,

Owing to the layout of my forms I want to have a asp:label tag styled using the same style as labels attached to a RadTextBox, combo box etc.  How would I reuse this?  Using the CSSClass="riLabel" on the username label doesn't seem to do anything so I assume that there is some level of specification behind it.  What would be nice is a RadLabel component...

<tr
    <td class="gridAdminLabel"><asp:Label CssClass="riLabel">Username:</asp:Label></td>
    <td class="gridAdminCell">
        <telerik:RadTextBox ID="uxUsername" Text="" runat="server" CssClass="formTextBox"></telerik:RadTextBox>
        <asp:RequiredFieldValidator ID="uxUsernameReq" runat="server"  ControlToValidate="uxUsername" ErrorMessage="RequiredFieldValidator"
            Text="<img src='/blank.gif' alt='Required field' class='errIconTextBox' />" Width="0" ValidationGroup="LoginValidationGroup"></asp:RequiredFieldValidator>
    </td>
</tr>


Regards,

Jon

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2011, 01:12 PM
Hello,

Try the following CSS.
CSS:
<style type="text/css">
   .riLabel
   {
      font: 12px "segoe ui" ,arial,sans-serif !important;
   }
</style>

ASPX:
<asp:Label ID="Label 1" runat="server" CssClass="riLabel" Text="Username"></asp:Label>

Thanks,
Princy.
0
Kevin
Top achievements
Rank 2
answered on 08 Dec 2011, 02:28 PM
Hello Jon,

You can either enter the style as Princy mentioned or you can could just do this:

<tr>  
    <td class="gridAdminLabel RadInput RadInput_Default"><asp:Label CssClass="riLabel">Username:</asp:Label></td>
    <td class="gridAdminCell">
        <telerik:RadTextBox ID="uxUsername" Text="" runat="server" CssClass="formTextBox"></telerik:RadTextBox>
        <asp:RequiredFieldValidator ID="uxUsernameReq" runat="server"  ControlToValidate="uxUsername" ErrorMessage="RequiredFieldValidator"
            Text="<img src='/blank.gif' alt='Required field' class='errIconTextBox' />" Width="0" ValidationGroup="LoginValidationGroup"></asp:RequiredFieldValidator>
    </td>
</tr>

I added the RadInput and RadInput_Default (if you're using the Default skin, you will need to change it if using another skin or if using the RadSkinManager you could change it to this "RadInput_<%# Container.Skin %>") classes to your label cell, so that the correct styles are applied to your label and they match the one used by the actual RadTextBox label.

I hope that helps.
0
Jon
Top achievements
Rank 1
answered on 08 Dec 2011, 02:50 PM
Hi Guys,

Many thanks for your help.  I'm working on an adapted version of Kevin s suggestion as I wanted to get the colour from the skin as well.  My seup uses the skin being in a key in the web.config file so I needed to get it from there.

It works for setting the style - with the exception of colour :(  

<td class='gridAdminLabel RadInput
RadInput_<%=System.Configuration.ConfigurationSettings.AppSettings("Telerik.Skin") %>'>
<
asp:Label CssClass="riLabel">Username:</asp:Label>
</
td>

I've checked to make sure that I haven't set the label to black anywhere and I haven't.  Is there some other thing that has been missed?

Regards,

Jon
Tags
Input
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kevin
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Share this question
or