Set ASP.NET set checkbox InputAttributes class in markup?

I just learned that <asp:checkbox CssClass="xyz"> puts the class tag in a span surrounding the rendered checkbox input element. I can add the class to the input element using server side code such as:

MyCheckbox.InputAttributes("class") = "xyz"

Is it possible to do this somehow directly from the aspx markup?

Thanks in advance.
LVL 1
ZekeLAAsked:
Who is Participating?
 
gamarrojgqConnect With a Mentor Commented:
Hi,

No, you can do that in the Checkbox markup declaration, but you can change your CSS like this


THIS WILL AFFECT THE CHECKBOX
.xyz
{
      background-color: blue;
      }

THIS WILL AFFECT THE DISPLAYED TEXT
.xyz label
{
      background-color: Red;
      }

Hope that helps
0
 
HainKurtSr. System AnalystCommented:
did you try

<asp:checkbox Class="xyz">
0
 
ZekeLAAuthor Commented:
class is not a valid attribute of asp:checkbox
0
 
ZekeLAAuthor Commented:
I'm using the class for jquery statements so it pretty much has to be on the element itself. Thanks anyway. Knowing it can't be done is a sufficient answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.