Can't use attributes.add for checkbox?

P

Paul W

Hi -

Why does this code:

Dim mychk As New CheckBox
mychk.Attributes.Add("Resid", "R" & 123213)
mychk.ID = "chk3"

render as this:

<span Resid="R123213"><input id="chk3" type="checkbox" name="chk3" /></span>

instead of this:

<input Resid="R123213" id="chk3" type="checkbox" name="chk3" />

If I use a textbox, instead of a checkbox then I get a version of the second
html, as desired.

Thanks, Paul.
 
I

intrader

Hi -

Why does this code:

Dim mychk As New CheckBox
mychk.Attributes.Add("Resid", "R" & 123213)
mychk.ID = "chk3"

render as this:

<span Resid="R123213"><input id="chk3" type="checkbox" name="chk3" /></span>

instead of this:

<input Resid="R123213" id="chk3" type="checkbox" name="chk3" />

If I use a textbox, instead of a checkbox then I get a version of the second
html, as desired.

Thanks, Paul.
I presume that the MS team is doing this to allow for checkbox lists!
 
P

Paul W

Thanks - using the "Onclick" works ok, but using "name" still creates a
<Span>. Guess I'll have to find an obsure 'real' attribute to use - any
suggestions?

Paul.
 
Joined
Nov 9, 2008
Messages
1
Reaction score
0
That interfering span in creating new CheckBox

Dear Paul,

I don't know if you are still out there. I followed your thread as I am experiening the same, yet I have not had your same success. Under my requirement it is imperative that I provide dynamic generation of rows with a checkbox at each. Yet in the generation the checkbox is always preceded by a span which interferes with checkbox change events. The checkbox (or any other toggling device, eg, one image then another) will be used as a device to add to a cart of sorts.

If you or anyone else could assist me with this matter I would be very grateful.

dunloe
 
Joined
Dec 17, 2008
Messages
1
Reaction score
0
There is a special property called InputAttributes that accesses the attributes of the underlying <input> tag.
So if you wanna add an non-standard attribute to a radiobutton or a checkbox, you should do

myChk.InputAttributes.Add("MyAttrivute", SomeValue)
 
Joined
Feb 3, 2009
Messages
1
Reaction score
0
Thanks!

Sweko,
Thanks for posting your response! It's always nice when someone who knows what they are talking about replys to these posts ;) :beer:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,383
Latest member
EzraGiffor

Latest Threads

Top