Monday, 23 April 2012

ASP.NET: AJAX Combo Box Item List placement problem - CSS Hacks

Occasionally, I like to use the ComboBox control from the Ajax Control Tookit. I hadn't used it for quite a while and added one to a recent project - one which I need to work in Chrome, Firefox and IE.
But the issue was that the ComboBox's item list would appear in a random place on the page, about 150 pixels away from the text box. No good.
It seems to be related to my use of Master pages but I couldn't find a solution which worked, so I decided (reluctantly) to hack the CSS. On my ComboBox control I have the CssClass set to 'CustomComboBoxStyle' and in my CSS I have a default selector for Chrome, then a hack for Firefox, followed by a second hack for IE 8 and 9 (if you're on any version of IE below 8, I don't care about you). The CSS ended up looking like this:

/* AJAX Combo Box Styles - HACKS here for item list */
.CustomComboBoxStyle table {margin-bottom:3px!important; top:0px!important;}
.CustomComboBoxStyle {position:relative;} 
.CustomComboBoxStyle ul { 
    position:absolute ! important; 
    left:2px ! important; 
/* Chrome - default */
.CustomComboBoxStyle ul 
    top:2px ! important;    
/* Firefox */ 
@-moz-document url-prefix() {
        .CustomComboBoxStyle ul {
        top:22px ! important;
/* IE 8 + 9 */
.CustomComboBoxStyle ul 
    top:15px \0/ !important;    

<asp:ComboBox ID="cmbCity" runat="server" 
    ItemInsertLocation="Append" CssClass="CustomComboBoxStyle"  >
    <asp:ListItem Value=""> -- Select city -- </asp:ListItem>
    <asp:ListItem Value="Aberdeen"></asp:ListItem>
    <asp:ListItem Value="Dundee"></asp:ListItem>
    <asp:ListItem Value="Edinburgh"></asp:ListItem>
    <asp:ListItem Value="Glasgow"></asp:ListItem>
    <asp:ListItem Value="Paisley"></asp:ListItem>
    <asp:ListItem Value="Perth"></asp:ListItem>
    <asp:ListItem Value="Stirling"></asp:ListItem>

In my solution, this worked (with pangs of guilt at such hackery). I absolutely do not guarantee or even assert that it will work for you, but it could be worth a shot. 

Monday, 16 April 2012

HP N40L Windows Home Server 2011: Mount Linux EXT2 drive and clone disk

Realising that I needed a home server to keep all my files on and run IIS, SQL Server etc, I recently upgraded from my D-Link DNS-320 to an HP N40L Microserver.

Of course, I needed to copy my files from the DNS-320 (Linux) to the N40L (Windows) and didn't fancy leaving it to copy the files over the network and I couldn't get Windows to mount the drive (when you put the Linux formatted disk into the N40L, Windows can see the physical disk but can't mount it as a drive with a letter etc).

So after rooting around a bit for solutions regarding mounting Linux EXT2/EXT3 drives in Windows, I found EXT2 File System driver on SourceForge and installed it (version 0.51). Then I put the drive from the DNS-320 into the new server and booted it up.

Note that the main solution which tends to come up is EXT2 IFS, which at the time of writing wasn't compatible with WHS 2011 (though it works with Windows 2008). So that was of no use to me but if you're running a supported version of Windows it may be of use to you.

Back to the problem in hand; when I ran the EXT2 volume manager I was able to mount the drives in Windows and use SyncToy to clone one disk to another - since the intention is to copy the data off the Linux drive and then once done, format with NTFS.

It worked nicely for me, and I hope this info is of use to someone!