VS / CLR (minor) Issue
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvs' list.


Matthew Tamm
Just found an annoying little issue...

If a have an <asp:checkbox runat="server" id="myCheckbox" text="A Checkbox"
/>

In my code-behind I will add a custom attribute:

myCheckbox.Attributes.Add("myCustomAttribute", "myCustomValue");

the problem is, this is rendered as:

<span myCustomAttribute="myCustomValue"><input type="checkbox"
id="myCheckbox" name="myCheckbox"><label for="myCheckBox">A
Checkbox</label></span>

As you can see, the custom attribute is added to the SPAN of the rendered
control, but not on the actual checkbox control, where you would expect and
need it to be.

Thank you

Matthew

Reply to this message...
 
    
Andy Smith
I found this issue as well, and a workaround is to use the =
HtmlInputCheckbox instead of the CheckBox.

This behavior happens because the CheckBox supports adding a label to =
it, and they wanted to make sure that any styles or such that you apply =
to the CheckBox, also apply to the label. ( I'm assuming there )

the HtmlInputCheckbox gives you more control over the rendered tag, so I =
suggest you use that instead.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

[Original message clipped]

Reply to this message...
 
    
Matthew Tamm
exactly where I went! Bummer that you lose the label though. Guess you
can't have it all!

Matt.

----- Original Message -----
From: "Andy Smith" <Click here to reveal e-mail address>
To: "aspngvs" <Click here to reveal e-mail address>
Sent: Monday, July 15, 2002 1:44 PM
Subject: [aspngvs] RE: VS / CLR (minor) Issue

I found this issue as well, and a workaround is to use the HtmlInputCheckbox
instead of the CheckBox.

This behavior happens because the CheckBox supports adding a label to it,
and they wanted to make sure that any styles or such that you apply to the
CheckBox, also apply to the label. ( I'm assuming there )

the HtmlInputCheckbox gives you more control over the rendered tag, so I
suggest you use that instead.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

[Original message clipped]

Reply to this message...
 
 
System.Web.UI.WebControls.CheckBox
System.Windows.Forms.CheckBox




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com