Style in asp control

  • Thread starter Thread starter simonZ
  • Start date Start date
S

simonZ

I have checkBox control:
<asp:CheckBox runat="server" ID="chkDelete" Checked="true" />

In code behind, I add stlye to this checkBox:
chkDelete.Style.Add("display", "none");

When page is rendered to the client, the style is performed with span:
<span style="display:none;"><input id="ctl00_ContentPlaceHolder1_chkDelete"
type="checkbox" name="ctl00$ContentPlaceHolder1$chkDelete" checked="checked"
/></span>

and I can't change it with javaScript.


It should be like this:
<input id="ctl00_ContentPlaceHolder1_chkDelete" style="display:none"
type="checkbox" name="ctl00$ContentPlaceHolder1$chkDelete" checked="checked"
/>

If I do with css, the result is the same.

How can I change that?

regards,S
 
You could use the attributes collection of the checkbox instead, such as
chkDelete.Attributes.Add("style","display:none;"); That's usually what I do
to get around this and guarantee that it renders as I wish it.
 
Back
Top