0

I would like to apply stylesheet class for controls based on some conditions. Say

If (RepeatedUser)
{
    applyThisStyleSheetClass
}

else
{
   applyAnotherStyleSheetClass
}

Do i need to create any custom control /Custom Property / Extension method to achieve this?

1
  • One way si to use jQuery on document.ready check for if repeater is used then change class. Commented Jun 16, 2013 at 1:17

1 Answer 1

2

You could try an extension method

 public static void ApplyCss(this WebControl control, string cssClass)
 {
        control.CssClass += " " + cssClass;
 }

You can use it in your code

If (RepeatedUser)
{
   Label1.ApplyCss("GreenClass");
}

else
{
   Label1.ApplyCss("BlueClass");
}
Sign up to request clarification or add additional context in comments.

Comments