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:

CSS
/* 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;    
}

Markup
<asp:ComboBox ID="cmbCity" runat="server" 
    AutoPostBack="False" 
    DropDownStyle="DropDownList" 
    AutoCompleteMode="SuggestAppend" 
    CaseSensitive="False"  
    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>
</asp:ComboBox>

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!

Monday, 12 March 2012

Come on Apple, get your Googles on and see the need for widgets!

I am tired of Android.

I find it to have generally poor implementation in a lot of apps, poor usability and half-hearted attempts to Apple-ify the user experience. There have been vast improvements in the past few months, but it's still lacking.

After I'd had my iPhone 3GS for 18 months I genuinely wanted to give Android a chance, not only because I was tired of the locked-down iOS ecosystem, but because I thought maybe it was a viable alternative for the fairly serious phone user.

Having owned an Android phone in the form of an HTC Desire HD for over a year, I am on the verge of returning to Apple via iPhone, iPad and my next computer will be a MacBook.

In my opinion, Android is the PC of phones and tablets. It's just not quite there. There's no 'ooh-ahh', in the experience - just mediocrity. I want a tablet for home and travel, but I wouldn't consider an Android tablet for a minute - not even with the knocked down prices we're seeing at the moment. I'm intrigued by Windows 8, but it's too long away.

Now to the point - my only sticking point with my return to iOS is homescreen widgets.

The best thing about Android is the great widgets you can add to your homescreen. Instantly accessible and useful information, quick shortcuts to the information you need, and general interest. Every section of my homescreen is rammed full of something I find useful.

Compare that to iOS' sweety box of colourful icons which mean virtually nothing. You can see which apps you have to launch as well as a few basic pieces of information, but nothing particularly useful to you at a glance. I really wish Apple would realise that they need to add user widgets to the iOS homescreen - the lack of widgets was one of the reasons I plumped for Android 12 months ago and it's the only thing which somewhat puts me off buying Apple iOS devices.

If I think that, then I very much doubt I'm alone.

Sort it out Apple - you may have queues out the door and up to the distant horizon when you launch a new product, but that queue could be a few people longer if you do the right thing and add widgets to iOS.

Saturday, 10 March 2012

Dell laptop: HDMI output has black border

When I upgraded to WIndows 7, my Dell Studio 17 suddenly lost the ability to display 1920x1200 (1080p) in full screen mode, either on the laptop display or my Philips 24 inch monitor.

I couldn't find any answer to it within the Windows display settings or control panel, and after a long time rooting around on Google and trying various things, I discovered I needed to:

a) Download the latest Catalyst drivers and control suite.
b) Once installed, use the 'scaling options' to adjust the size of the output display to 'match my flat panel'.

Finally! Back to a usable full screen without having to compromise on resolution.

Wednesday, 1 February 2012

Solved: DNS-320 P2P folder disappeared

I upgraded the firmware on my D-Link ShareCenter Pulse DNS-320 to version 2.02, and suddenly the P2P folder disappeared.

I thought everything had been deleted, but it continued to download torrent files - where was it saving them to?

Turns out that the new firmware changes the way your P2P folder is shared on your network, and that all you need to do is disable and then re-enable the P2P service using the web interface.

Back to normal!

Tuesday, 17 January 2012

Solved: Visual Studio 2010: ASP.NET project - can't add web reference

I hadn't worked on a project for a while (since upgrading to Visual Studio 2010), and I needed to add a web reference to get it to compile. The normal method is just to right-click on your project name in Solution Explorer and click Add Web Reference.

But I had no option to Add Web Reference, only an option to 'Add Service Reference' which seems to be designed for WCF references.

It's a legacy project though, so I needed to add the reference in the legacy format - adding a service reference creates different components in your project than a web reference.

I got round it by:

1. Change the target framework to .NET 2.0
2. Close and reopen the solution - you should see the option to Add Web Reference.
3. Add the web reference.
4. Change the target framework back to whatever you had before.
5. Close and reopen the project.
6. Continue upon your way.

This might not work for everyone since I don't really know why the option to add web reference disappeared in the first place - but it worked for me.

Friday, 16 December 2011

Lots of screens? Lots of windows? WindowPad!

I use three screens for work, and I usually have about 12-15 windows open at once. I'm also a bit precious about the window sizes and positions of the things I'm working with - especially when using Visual Studio or another tool with a lot of dockable windows.

I hate having to drag windows about and manually resize them. Enter WindowPad!

It's a little utility which consists of an executable file and an ini file for configuration - you just put it in your Startup folder to use.

WindowPad uses a virtual "pad" to arrange windows, where you can use the Numpad to move and resize windows to fill the appropriate sections of your screens.

Features include:
- Move windows within the current monitor or between monitors (in multi-monitor setups).
- Customize hotkeys via WindowPad.ini with AutoHotkey-like command syntax.
- Define custom commands as labels or functions in WindowPad.ahk.
- Execute WindowPad commands specified on the command-line.

This is one of the tools mentioned in my .NET tools post, but it's the best utility I've discovered in a long time.

Friday, 9 December 2011

Power tools every .NET developer should have

Working every day within a Windows environment, you get used to your own specific way of customising your workspace.

I'm always on the look out for ways to make my laziness less of an issue by being able to do common tasks more quickly, and Scott Hanselman's Ultimate Developer and Power Users Tool List for Windows is brilliant.

There are some really useful applications on there and in particular I liked WindowPad because it helps you to quickly arrange the various Visual Studio windows on your screens rather than having to drag and resize constantly.

Wednesday, 23 November 2011

Visual Studio: Selecting which browser to debug with

I love Google Chrome. It's fast to start up, fast to render pages, it knows how to use CSS and it's just generally excellent.

I'm less keen on IE though. However, since it's the most popular browser that's the one I tend to debug my web applications with. But Visual Studio kept launching Chrome instead of IE - turns out it's a simple fix:

1) Right click on a .aspx page in your solution explorer
2) Select the "browse with" context menu option
3) In the dialog you can select or add a browser. For example, if you want Firefox in the list click "add" and point to the firefox.exe filename
4) Click the "Set as Default" button to select the default browser when you run any page on the site.

Works. Life made easier.

Solution bumped from Stackoverflow.

P.S.: If you don't see a 'Browse with' option - check you're not debugging already! Stop debugging and the option will appear.

Tuesday, 30 August 2011

Windows Remote Desktop: The terminal server has exceeded maximum number of allowed connection, mstsc

I kept getting the dreaded 'The terminal server has exceeded maximum number of allowed connection' when attempting to log onto a remote server. I must've forgotten to log out and just clicked close on the mstsc session!

The answer:

You can start a control session to the server and logoff your other connections. Please always use "LogOff" when you leave remote desktop.

Open Command Prompt.
Type: "mstsc /admin".
Remote Desktop Connection will start. Type the computer name or IP address of the computer you want to connect to in the Computer box.
Configure any other desired options, and then click Connect.

Solution from the page at this link