ListItem.AddAttributes has no affect?

P

PV

I am trying to add some attributes to a DropDownList's list items.

For Example
dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
"myExpandoValue");

I would expect then the rendered html to look like:

<select name="dropdownList1" id="dropdownList1">
<option value="test" myExpandoProperty="myExpandoValue">test</option>
</select>

However, the expando property does not show up. What's the point of having
an attributes collection if it does not get rendered in the HTML!?

Any idea how to do this?
 
P

PV

And as an added bonus, it is a sealed class. So I can't inherit from the
thing and implement it properly. Just great.

Any chance of a hotfix?

As it stands, it looks like I would have to implement my own DropDownList
control just so that I can add my own correctly implemented ListItem objects
to it (at least dropdownlist isn't sealed). Would that be a correct
assesment?

Alvin Bruney said:
That's a well documented bug. There is currently no work around.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
PV said:
I am trying to add some attributes to a DropDownList's list items.

For Example
dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
"myExpandoValue");

I would expect then the rendered html to look like:

<select name="dropdownList1" id="dropdownList1">
<option value="test" myExpandoProperty="myExpandoValue">test</option>
</select>

However, the expando property does not show up. What's the point of having
an attributes collection if it does not get rendered in the HTML!?

Any idea how to do this?
 
A

Alvin Bruney [MVP]

You may be able to write to it if you replace the listbox with a select tag.
I've not tried it but i suspect it is better than waiting for a hot fix. The
next hotfix is whidbey which is a while away.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
PV said:
And as an added bonus, it is a sealed class. So I can't inherit from the
thing and implement it properly. Just great.

Any chance of a hotfix?

As it stands, it looks like I would have to implement my own DropDownList
control just so that I can add my own correctly implemented ListItem objects
to it (at least dropdownlist isn't sealed). Would that be a correct
assesment?

Alvin Bruney said:
That's a well documented bug. There is currently no work around.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
PV said:
I am trying to add some attributes to a DropDownList's list items.

For Example
dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
"myExpandoValue");

I would expect then the rendered html to look like:

<select name="dropdownList1" id="dropdownList1">
<option value="test"
myExpandoProperty="myExpandoValue">test said:
</select>

However, the expando property does not show up. What's the point of having
an attributes collection if it does not get rendered in the HTML!?

Any idea how to do this?
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,082
Latest member
KetonaraKetoACV

Latest Threads

Top