May 2007

Encoding HTML Entities in an ASP.NET DropDownList

I ran into this one today, alternative solutions are welcome…

If you’re programatically adding items to an ASP.NET dropdown list, you do it with something like this:

_cboDropDown.Items.Add(new ListItem(”Item Text”, “Item Value”));

Which is fine for most cases, but unlike with, say, the Text property of the Label control, ASP.NET will HTML encode the text before rendering it, so if you have something like:

_cboDropDown.Items.Add(new ListItem(”Brand X®”, “1131″));

It’ll show up in the dropdown as “Brand X®” instead of the intended “Brand X®”

What’s a poor developer to do?

I ended up using the Server.HtmlDecode() method, as follows:

_cboDropDown.Items.Add(new ListItem(Server.HtmlDecode(”Brand X®”), “1131″));

…and it’s all good, if a little ugly for my tastes. Has anyone got a better idea?

.Net

Comments (1)

Permalink

Metro Toronto .NET User Group: Grok Talk 2007

I finally made it to a Metro Toronto .NET User Group meeting last night. The format was great, with 4 short talks ensuring that if something was too far out of my area of interest the night wouldn’t be a write-off. As it happened, they were all excellent.

I especially enjoyed Mark Piotrowski’s introduction to Dali - I was about to do another search for a simple O/R mapper and this looks like it might fit the bill, assuming I can get it working with MySQL. I’ve been split between code generators and ORM lately, with both the commercial stuff I’ve seen and our homegrown semi-solutions not quite fitting, but this looks like it might be something I can evaluate without having to book a day or two of work just to research. Cool.

Also, Jean-Luc David did an XNA demo, and attempted to make Pong funner by applying a guitar theme, including power chord sound effects and use of a Guitar Hero controller. He did a good job of using zoom during his demo, but made one crucial mistake - when doing a demo involving power-chords, if you’ve got the opportunity to boost the speed of an object from 3 to something else, do you pick 7, as Jean-Luc did? No. You pick 11.

The other two demos (Rob Windsor on encryption, Randar Puust on Silverlight) were good as well, but as I won’t be doing anything with them in the next few weeks, I can’t do much about them other than to make some mental bookmarks (and no, I won’t be making a pong game either, but any excuse to get Guitar Hero…)

Training

Comments (0)

Permalink

De-twittered

Minor site update - I dropped the Twitter widget from the sidebar, what with not having updated the thing in a while. I kinda came to dual realizations that a) I don’t do a lot of stuff that anyone on my friends list would find interesting and b) I can do a lot more stuff when I don’t write about what I’m doing in the first place (this also feeds back to the sparse updates here as of late).

On a related note, I highly recommend The Four Hour Work Week by Tim Ferriss. I’ve had two concrete takeaways so far - checking email twice a day and separating location from function.

Tim recommends checking your email at noon and 4. I haven’t been totally successful on this one, but it’s been amazing how many situations I’ve been in where I’ve replied to something at noon, expecting resources to come back to me that need to be acted on right away, only to receive them at 5 (or later). In the past, this would rob me some serious time, checking the inbox everytime it dinged, etc. So far, no ill effects from the new email schedule, and I haven’t even set the autoresponder up yet (but again, I manage to do this maybe twice a week at this point).

I’ve also started working at the local library, which has no internet access and a strict no cell phone policy. It’s not suitable for every task (let’s just say that dual monitors can be a blessing and a curse), but coding full screen with no online diversions available is a huge thing. I don’t have access to source control or online docs, and there’s an integration phase when I get into the office, but I’ve been able to churn out some serious chunks of new code through this process. Bonus: the library’s near some restaurants I don’t normally get to frequent, and their lunch specials rock…

Technorati Tags: , ,

GTD

Comments (0)

Permalink