Archive for June, 2008

Brisbane .NET User Group – aka QMSDNUG

June 24, 2008 - 4:40 pm No Comments

On Tuesday, Chris and I went along to our first .NET User Group (or Queensland MSDN User Group) meeting here in Brisbane. Having attended a few back in Wellington, I thought it would be nice to check out the Brisbane version.

The meetings are held in the Brisbane Microsoft offices, in a very very flash building down town. Like usual, the meeting started off with pizza and soft drinks which is always much appreciated by those attending. The crowd started off small but within a few minutes, there were a lot of people there – I’d say at least 40 or so showed up, not bad (of which only about 3 were girls but that’s to be expected!). The couple of .NET User Group meetings I went to in Wellington were probably about half this size but then again I guess Wellington is a much smaller city than Brisbane.

The topic for the evening’s talk was “Silverlight 2.0 and WPF – what’s the same, what’s different?”. The speaker, Joseph Cooney, was very well informed and well spoken. As the title would suggest, he compared Silverlight 2.0 and WPF but not to try and say that one was better than the other. Instead he wanted to try and inform the audience as to why you would want to choose one over the other, what situations suit which more.

What I took away from Joseph Cooney’s talk is that Silverlight is basically a lightweight version of WPF. It’s meant to be a 4~5mb download and you really can’t package up too many libraries in that. In order to keep that size down, Microsoft have removed mundane values such as all but the main HTML colors in the Color namespace. Really, who even knows what CornflowerBlue looks like??

There are some controls which are only available to WPF and like-wise, others which are only available to Silverlight. I guess this means you can’t really call Silverlight a subset of WPF.

I can’t wait to get to use WPF and/or Silverlight in a commercial manner and hope to start on a project at work or at home that’ll let me spend a bit of time investigating these new libraries and what they’re capable of!

And as for the Brisbane .NET User Group, it looks like a great place for networking and meeting other like minded .NET-geeks so I’m sure I’ll be turning up to future meetings.

  • Share/Bookmark

Enabling & Disabling ASP.NET radio buttons using code-behind and JavaScript

June 19, 2008 - 12:35 am 5 Comments

I have just come across a strange problem when trying to disable some radio buttons on a web page using .NET and JavaScript. It seems to work well in Firefox but not IE, what a surprise!

The situation:

I have two sets of radio buttons – two RadioButtonList controls. The first set needs to control the second set – that is, when one of the radio buttons in the first set is selected, the other RadioButtonList control should be enabled, and when the other of the radio buttons in the first RadioButtonList control is selected, the second RadioButtonList control should be disabled.

In my code-behind, I had an event handler for the first RadioButtonList control to check if the selected index had changed. If so, check the value of the first RadioButtonList control and if it’s say equal to 1, then set the Enabled property of the second RadioButtonList control to false. Otherwise, set the Enabled property to true.

Obviously this alone doesn’t fix the problem unless the first RadioButtonList control is set to AutoPostBack = True. I needed some code on the client side to do this when while the user wasn’t posting the page back.

The code to disable some radio buttons is simple:

?View Code JAVASCRIPT
1
2
3
4
var secondRadioButtons = document.form1.secondRadioButtonList;
for(var i=0; i<secondRadioButtons.length;i++ ){
    document.form1.secondRadioButtons[i].disabled = false;
}

The problem:

When you wire all this up, it works fine in Firefox… But does it work in IE? No, of course not. So why not? I found that when I first loaded the page, the radio buttons were enabled / disabled as they should have been. Clicking on the first set of radio buttons was disabling / enabling the second RadioButtonList control as it should have. But as soon as I posted the page back (the page had a button that submitted a form and displayed some results), the second RadioButtonList control was completely disabled and no matter which of the first radio buttons I selected, I couldn’t re-enable it. I stuck some debug code in my JavaScript only to find that it was running correctly and firing when it should. As far as I could tell, the JavaScript was setting disabled = false (as above) on all of the radio buttons in the second RadioButtonList control, but they were still disabled. Why!?

I took a look at the source code for the page and noticed something that I thought might have been causing the problem I was experiencing. Basically, browsers renders an asp:RadioButtonList control like this:

1
2
3
4
5
6
<span id="secondRadioButtonList">
<input id="secondRadioButtonList_0" name="secondRadioButtonList" value="1" type="radio" />
    <label for="secondRadioButtonList_0">First radio button</label>
<input id="secondRadioButtonList_1" name="secondRadioButtonList" value="2" type="radio" />
    <label for="secondRadioButtonList_1">Second radio button</label>
</span>

If you disable a RadioButtonList in your code-behind, the same asp:RadioButtonList control will be rendered like this:

1
2
3
4
5
6
7
8
<span id="secondRadioButtonList" disabled="disabled">
    <span disabled="disabled">
<input id="secondRadioButtonList_0" name="secondRadioButtonList" value="1" disabled="disabled" type="radio" />
        <label for="secondRadioButtonList_0">First radio button</label>
<input id="secondRadioButtonList_1" name="secondRadioButtonList" value="2" disabled="disabled" type="radio" />
        <label for="secondRadioButtonList_1">Second radio button</label>
    </span>
</span>

This is precisely why I don’t like asp controls – they look nice in the html that you write yet when they render out to the browser, they’re filled with extra stuff like these two spans.

Anyway, the problem were these spans – obviously even though I was setting ‘disabled = true’ on all the radio buttons inside my asp:RadioButtonList control, there were a couple of spans around the radio buttons that were also disabled causing my radio buttons to appear disabled regardless of their individual status.

The solution:

My solution to this was to simply remove the code-behind that I had written to enable or disable the RadioButtonList control on the server side. My JavaScript is all I really need.

However, if you desperately want or need to have some server-side code also disabling your radio buttons, you should do so like this:

?View Code CSHARP
1
secondRadioButtonList.InputAttributes.Add(”disabled”, “disabled”);

rather than

?View Code CSHARP
1
secondRadioButtonList.Enabled = false;
  • Share/Bookmark

Where is my SQL Server 2005 Management Studio?

June 10, 2008 - 11:54 pm 5 Comments

I’ve just had the toughest time getting SQL Server 2005 WITH Management Studio installed, so I thought I would blog about my thoughts on the matter and my rather round about way of getting it going.

1 – Install SQL Server 2005 Developer Edition. Stick Disk 1 in. Everywhere says ‘click on the link to start the SQL Server Installation Wizard.’ Well guess what, there isn’t a link that says that! There are two links, one to install components and another to install SQL Native Client. Grr.

2 – I click on the components one and it seems to install everything I need to run SQL Server 2005, EXCEPT for Management Studio. Why? I don’t know. I do however wonder why it never asks me for Disk 2… hmm.

3 – Open up Control Panel, Add or Remove Programs. Look for “Microsoft SQL Server 2005”. Click on the “Change” button.

4 – Select the ‘SQL Server 2005 common components > Workstation Components’ option and hit Next. When you are finally given the option to ‘remove’ this component, do it. Just do it.

5 – Once this is all finished (takes forever!), repeat step 3. When you are shown the the same dialog box as in step 4, there won’t be a ‘SQL Server 2005 common components > Workstation Components’ option. Instead there will be some text telling you you should use the ‘To install a new component, click here’ link at the top of the dialog box. Click this link. This will open up a series of dialog boxes very similar to those encountered in step 2 – your basic installation. Select the last option (I think it was ‘Tools’?).

6 – It should tell you it’s going to install a bunch of stuff and then start installing it all… pretty quickly however, it will ask you to insert Disk 2. This is a good sign.

7 – Insert Disk 2.

8 – Wait for the installation of all the different components to complete.

9 – And like magic, you should now have a whole bunch more shortcuts in your start menu under Microsoft SQL Server 2005. Although this seems like all you did was install, uninstall and re-install, believe me, it’s the only way I managed to get it to work.

As I said above, I’m not sure if I’m the only person this has ever happened to but I have seen plenty of other blog articles on how to get Management Studio installed if it doesn’t appear to be there already so I believe I’m not alone. None of the other solutions I saw helped me either so hopefully this will help someone else in the same position as me!

  • Share/Bookmark

Fatal error: Call to a member function decode() on a non-object in /home/geekchick/www/www/wp-content/plugins/twitter-tools/twitter-tools.php on line 744