Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1640
  • Last Modified:

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.
0
ZekeLA
Asked:
ZekeLA
  • 2
1 Solution
 
HainKurtSr. System AnalystCommented:
did you try

<asp:checkbox Class="xyz">
0
 
ZekeLAAuthor Commented:
class is not a valid attribute of asp:checkbox
0
 
gamarrojgqCommented:
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
 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now