Bug in ASP.NET 1.1 (ListItem) - Stuart Gunter
in

dotnet.org.za

South African .NET Developer Portal

This Blog

Syndication

News


Get Firefox!
<!-- Begin Nedstat Basic code --> <!-- Title: StuartGunter --> <!-- URL: http://dotnet.org.za/stuartg/ --> <!-- End Nedstat Basic code -->

Stuart Gunter

There's too much!

Bug in ASP.NET 1.1 (ListItem)

I've been desperately trying to get this to work, but the more I research the more I realise it's not do-able! I've been trying to get attributes added to a ListItem using the ListItem.Attributes.Add() method, but it seems that none of these render to the client! What's the point of it being there?

I found another blog on this here... If anyone finds a solution, please post back!

Published Sep 07 2004, 11:27 AM by stuartg
Filed under:

Comments

 

StuartGunter said:

Ok... this is apparently "by design"
http://support.microsoft.com/default.aspx?scid=kb;en-us;309338&Product=NETFrame

I have no idea why this was designed in the first place. Surely it's something useful to have!?!? Any thoughts???
September 7, 2004 11:56 AM
 

StuartGunter said:

Well... the workaround was to register a startup script that disables the items that I choose. What a pain! Something like this shouldn't be such a mission... but then again, I could well be doing something wrong. The problem is that information is lacking on this topic!! No info found on either Google or Microsoft Search... (and yes, I did use Microsoft Search first ;)
September 7, 2004 1:25 PM
 

Thea Burger said:

I also had a look around and couldn't find any good info :( Good luck!!!
Ps: MSN search is really not too bad (y)!!
September 7, 2004 7:36 PM
 

Justin Lovell said:

There is no neat workaround, unfortunately. The neatest way that I know of is to inherit from the List control and work with the renderings yourself. Ie: override RenderControl and iterate through each item to output the correct HTML.
September 8, 2004 7:44 PM
 

StuartGunter said:

Thanks... I tried that, but sadly ListItem is a sealed class... no inheritance allowed. Bugger!
September 9, 2004 8:01 AM
 

Justin Lovell said:

Nah. You got me wrong here. Don't inherit from the ListItem class -- inherit from the List control(s).
September 9, 2004 9:33 AM
 

StuartGunter said:

Aaah.... will give that a try. Thanks!
September 9, 2004 9:40 AM
 

StuartGunter said:

Ok... if anyone still cares... I found a better way of doing this. I must've been doing something wrong with the HtmlSelect control, because is you use item.Attributes.Add("disabled", "disabled") then it DOES in fact render to the client.

I really do feel that this should've been built as part of the DropDownList WebControl... surely this would be a better way of doing it?

If anyone finds info on why it was designed out, please post it here... I'm sure there's a good reason, just can't think of it right now.
September 10, 2004 7:29 AM
 

Rohan Parkes said:

I've found that the htmlselect attribute still won't render if it is contained in another control such as an ASP tablecell. That might have been the problem.
March 31, 2005 8:41 AM
 

battaile fauber said:

According to http://support.microsoft.com/default.aspx?scid=kb;en-us;309338&Product=NETFrame it has something to do with "expando" attributes being supported in the html control but not the web control.
August 31, 2005 6:52 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Powered by Community Server (Commercial Edition), by Telligent Systems