Tuesday, 30 March 2010

Visual Web Developer 2008 Express failed (.msp association)

I had an issue today when installing the Express version of Visual Web Developer 2008.

The required files download and the install starts. Then it seemed to want to open a file in a paint package installed on the computer and after it failed in doing so, the installer crashed!

I guessed straight away it might be the association of the .msp file and sure enough, on looking, the .msp extension was associated to a paint package installed on the PC.

Thankfully I had a PC that had the association as it needed to be so I copied that and tried to install the program again.

Not sure what .msp has to so with a paint package or why the installer needs it but once I'd 'corrected' it, all worked well.

Here is the registry key and data required;

HKEY_CLASSES_ROOT\.msg

data = 'Msi.Patch'

Friday, 26 March 2010

CSS floating images and lists

I had a piece of text with an image floated within it that looked exactly as required.

Upon adding unordered list HTML in-between two of the paragraphs, the text above and below the list still looked fine but the bullet points of the unordered list were on the edge of the actual image.


It seems that floating images don't work with <ol> and <ul> commands the same as they do with <p> commands but the fix was to give the unordered list a style of a left margin which matched the width of the image (plus any margin the image itself may have).

<ul style="margin-left:210px;">

Thursday, 25 March 2010

ASP.Net (VB) fix for RadioButton's using GroupName in a Repeater

I've just had the experience of learning that due to the way a repeater renders, in terms of giving names to the controls within, the GroupName attribute doesn't actually work.

This is the official Microsoft bug: http://support.microsoft.com/kb/316495/en-us

I can understand why it fails but it's a little frustrating that the only solution I could find was a javascript one.I originally found it on this website but I wanted to write the script in my code behind and in VB rather than C#.

Here is the code I converted it to.

To start off with in the Page Load event I had

Dim objSB As New StringBuilder

objSB.Append("" & Environment.NewLine)
ClientScript.RegisterClientScriptBlock(Me.GetType(), "UniqueRadio", objSB.ToString)

This just inserts the required javascript at the top of the page (and it should validate OK).

Then within the ItemDataBound event, amongst all the other code in there I put

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim rb As RadioButton = DirectCast(e.Item.FindControl("RADIOBUTTONID"), RadioButton)
rb.Attributes.Add("onclick", "setUniqueRadioButton('rptList.*GROUPNAME',this)")
End If

The text in capitals are what needs replacing. The RADIOBUTTONID should be the ID of the radio button and the GROUPNAME should be changed to the group name being used.

If you had multiple 'groups' on the same page you should only need to use the second piece of code twice. The javascript at the top can be referenced throughout the page.

Thursday, 18 March 2010

IE6 floating div margin bug

A very simple one this. I had 2 div elements on my web page. One floated left and one floated right. They had margins to their edges and it looked exactly as required in all proper browsers. That of course doesn't include Internet Explorer 6 which has been one of the bane's of my life for ages now.

Anyway, thankfully it turned out to be an easy fix and, when implemented, it didn't cause issues with Chrome, Firefox etc

All I did was put

display:inline;

on each of the floating elements.

Monday, 8 March 2010

VB.Net - Stopping a form from being moved

I have just managed to finish what I thought would be a 5 minute task that ended up taking me a lot longer than that.

I have a VB.Net application and a form that the client doesn't want the user to be able to move (it needs to hide data that the user validates).

I found various suggestions on-line. The most common being to remove the border of the form. This does work but looks awful so I carried on looking.

I eventually found several code samples written in C# and managed to convert the simplest looking one to VB.Net. I pasted it in the code page for the form and it worked. So here it is....

Protected Overloads Overrides Sub WndProc(ByRef m As Message)
Const WM_NCLBUTTONDOWN As Integer = 161
Const WM_SYSCOMMAND As Integer = 274
Const HTCAPTION As Integer = 2
Const SC_MOVE As Integer = 61456

If (m.Msg = WM_SYSCOMMAND) AndAlso (m.WParam.ToInt32() = SC_MOVE) Then
Exit Sub
End If

If (m.Msg = WM_NCLBUTTONDOWN) AndAlso (m.WParam.ToInt32() = HTCAPTION) Then
Exit Sub
End If

MyBase.WndProc(m)
End Sub