¿Cómo utilizo css para la etiqueta de control de usuario?

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>

StyleSheet1.css

#Label2
{
    color:red;
    }

webform.aspx

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

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

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

preguntado el 02 de febrero de 12 a las 10:02

2 Respuestas

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.

Respondido 02 Feb 12, 14:02

Trata

uc1.Style["Color"] = "Red";

Respondido 02 Feb 12, 15:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.