Take the 2-minute tour ×

I want to change color of label which is in usercontrol. as it in in usercontrol i'm failed to do this using css.

I did like following : inside myusercontrol.ascx

<link href="StyleSheet1.css" rel="stylesheet" type="text/css" />
<asp:Label ID="Label2" runat="server" Text="user control"></asp:Label>




    <asp:Label ID="Label1" runat="server" Text="home" ></asp:Label>

      <uc:myuc  runat="server" ID="uc1"  />

As in normal aspx page it is working fine but not on usercontrol please suggest

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Never style against asp.net id:s since they might change in the markup. If you view source the label (rendered as a span) propably won´t have id="Label2" when it´s inside the usercontrol. Rather style it using a class or set clientidmode static if that suits your solution.

share|improve this answer
add comment


uc1.Style["Color"] = "Red";
share|improve this answer
add comment

Your Answer


