Adding JavaScript onclick event to Radio Button List items in VB.net

This is a very simple post covering how to capture of a Radio Button List item value using the JavaScript onclick event handler. I’ll start by assuming you already have the Radio Button List on your page and bound to a data source as follows:

<asp:RadioButtonList ID="rblItems" runat="server" DataSourceID="MyDataSource" DataTextField="MyDataTextField" DataValueField="MyDataValueField"></asp:RadioButtonList>

In your codebehind file, add the following to the DataBound event of the rblItems control:

Private Sub rblItems_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblItems.DataBound Dim rbl As RadioButtonList = DirectCast(sender, RadioButtonList) For Each li As ListItem In rbl.Items li.Attributes.Add("onclick", "javascript:DoSomething('" + li.Value + "')") Next End Sub

Finally, add the JavaScript ‘DoSomething’ method that will be referenced when the list items is pressed by adding this to your page:

     function DoSomething(object)     {     alert("You clicked on :" + object);     }

This code will show a JavaScript popup window with the value of the clicked Radio Button List item.

BlackBerry Bold: The Business iPhone?

When RIM announced the BlackBerry Bold in April of this year, they promised the ultimate BlackBerry in terms of form and function.  They have been kind enough to send us an evaluation unit which I spend some time playing around and I thought I’d take the opportunity to post my thoughts on the new model. In short?  The iPhone for Business.

This review will cover the aesthetics, operating system, connectivity options, multimedia and applications.

Aesthetics

I don’t think I have to say much here as I’m sure you can see from the photographs that the new design is fantastic. The curves on the device are much more accentuated than on previous models. The keyboard also feels much more comfortable to type on compared to the 8800 and the textured back cover makes it very comfortable to hold in one hand – something I miss with the iPhone 3G. A major usability improvement is the revised layout of the function keys.  The answer and drop call buttons much easier to press and are much bigger than previous models.

It looks like RIM realised that the textured leather back cover won’t appeal to everyone so they provided fully interchangable covers. 

 Operating System

The first thing you’ll notice about the new user interface is that it looks much neater then previous releases. Pressing the hot key brings up with full menu with a gradiented background. I’m glad they fixed this as the custom backgrounds on previous models just made the desktop look messy. The only complaint I have is that some of the icons are a bit cryptic – I had to hover over a few to fully understand what they were meant to represent.

The number of menu items per page has also been reduced as the 8800’s home screen looked a bit crowded. The Bold has 3 rows of 6 icons – if you have lots of applications, beware of scrolling.

Connectivity Options

Again, I don’t have to say much here. It has it all. Not only does the device support fast 3G data networks, it has GPS, and Wi-Fi built in as standard. As you’d expect, power hungry 3G networks drain the device battery much faster than GSM but you’ll still get a good run out of the 1500mAh battery – say 24 hours solid with a few hundred e-mails, few hours of calls and some web surfing. The BlackBerry definitely wins over the iPhone here. Additionally, the device supports A-GPS (Assisted GPS) meaning the device can instantly latch on to your current location based on information from the local mobile tower. This works really well.

Multimedia and Applications

The bold includes a wealth of applications and of course you can download new ones with ease either through your network’s portal, direct from the Internet or have them pushed through your business BlackBerry Enterprise Server. One big plus is the ability to open and edit Microsoft Office files, and the new *.docx format that so many legacy applications have a major problem with.

The multimedia player on the BlackBerry Bold is fantastic. You can sync iTunes playlists (except DRM protected tracks) to your device with the click of a button. What’s more you can combine this with ordinary ‘Windows Syncs’ through the BlackBerry Media Sync software included with the phone. What a welcome change from iTunes. All changes on your local PC are sent down to your BlackBerry next time it’s docked. No fuss, no hassle. The #1 improvement from a hardware point of view is the inclusion 3.5 mm audio jack enabling you to use your own headphones with the device. You can take photographs on the phone’s 2MP camera and the video player can cope with AVI and MPEG-4 formats plus the DivX and XviD codecs, WMV and 3GP. The resolution of the camera is exactly the same as previous models @ 2.0 Megapixels but the photo quality seems better. The games are definitely worth checking out. As well as the usual BrickBreaker (usually found on Windows Mobile), there’s Texas Hold’em King 2 Poker which is well done for the mobile. Two other major features which I didn’t screenshot were:

  • Tthe ability to view web pages ‘desktop style’, just like the iPhone. It’s really easy to operate with the trackball acting as a mouse, and what’s more it supports streaming media through the RSTP protocol.
  • The single biggest improvement on the device: The e-mail client. Not only does it deal with HTML emails, but the larger screen and better fonts make them easier to read.

Both of these features out perform the previous models when accompanied by a faster processor in the device and 3G network connectivity.

In Summary

What a device! If I hadn’t just bought an iPhone, this would be my next phone.