ASP.NET Gripe #1

Now don’t get me wrong. .NET is great and so is ASP.NET, but there are one or two things that irritate me. I currently use 2003, and maybe this is fixed in the next version, but it’s a real pain.
 
Attributes on ListItems don’t render.
 
What am I talking about and why is it a problem? In classic ASP, I often used custom attributes on list items so that I could use JavaScript to change a value in another field based on the selected item. So, for instance, I might have:
<select onchange="blah(this)">
<option value=5 OtherValue="Hello">Display Text</option>
…and then the blah() routine could pick up the OtherValue field and stick it somewhere else. ASP.NET seems to support this through the attributes collection on each element:
ListItem li = new ListItem("Display Text", "Value")
li["OtherValue"] = "Hello";
…but the OtherValue attribute doesn’t appear on your web page. The only workarounds I’ve found are far to hideous to publish on a public web page. Has anybody got these attributes to work?
Advertisements
This entry was posted in Computers and Internet. Bookmark the permalink.

3 Responses to ASP.NET Gripe #1

  1. Kevin says:

    Have you tried inheriting the control, overriding the render method and outputting your own html? That should give you complete controlSimilar problems in 2, by the way. My favourite so far – the xslt processor "cleaning up" my xml by turning empty elements into />… thus stopping the .js files from working….Cheers,Kevin

  2. Kevin says:

    Hi Rob,Yes, it was Me. The XSLT one is even worse than I thought. Asp.net 2.0 is xhtml compatible, right? Only if you use xml as the method for your xslt, it "cleans up" your divs etc., messing up your xhtml completely…. and if you use html, it turn br/ etc into br, thus messing up your xhtml….The only solution I\’ve found so far is to put non-breaking spaces into all the empty elements…. thus stopping it from "improving" them…. Oh joy.Cheers,Kevin

  3. wei says:

    The only way it seems is to rewrite it.But why MS do not resove the problem himself?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s