# Thursday, April 23, 2009

How to generate a list of Visual Studio Shortcuts

I'd seen addins that list Visual Studio shortcuts before, but seem to have lost them.  I also used to use ReSharper, so memorised its shortcuts.  I'm now back to 'naked' Visual Studio, so am having to re-learn the standard shortcuts.

I was surprised to find this article on MSDN that has code for a macro to produce a html page of all the shortcuts.  Just run the macro, open it up and search in the browser whenever you're having problems remembering - unless you really want to print it (in which case I'd be inclined to bang a bit of CSS in there :) ).  I might improve upon the whole situation if I find myself needing to refer to it more often, and will post updates here.

posted on Thursday, April 23, 2009 8:44:07 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [1]
# Wednesday, April 08, 2009

10 Essential Checks before releasing a Web Site

More goodness from Smashing Magazine

This is all fairly well known stuff, but it's amazinf how often I've seen sites go live without 'most' of these.  Now of course every website's different, but this is a great list for reference and for learning.

posted on Wednesday, April 08, 2009 8:02:57 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0]
# Monday, March 16, 2009

ASP.NET Data Binding - Accessing a parent data item from within a nested repeater

I'm maintaining an app at the moment that uses quite a few nested repeaters, and found that headers were being output when there was no data present.  It was found that the header was being written in the ItemTemplate of an 'outer' repeater, rather than as the HeaderTemplate of the 'inner' repeater.  The next problem was how to reference the outer repeater from the 'inner' HeaderTemplate...

The following will bind to a field called HeaderDescription.

<%# DataBinder.Eval(Container.Parent.Parent, "DataItem.HeaderDescription") %>

The parent of the inner item is it's repeater, so you have to go to it's parent to get the right RepeaterItem.  Why don't you just do the following you ask?

<%# DataBinder.Eval(Container.Parent.Parent.DataItem, "HeaderDescription") %>

..'cos it doesn't work - The Eval method expects a 'Control' as its first parameter.  There's other ways to do this server-side, but the first option is probably the easiest.

To complete the picture and only show when there's data you can add the following to the 'inner' repeater declaration

OnItemDataBound="ItemDataBound" Visible="false"

then..

        protected void ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item)
            {
                if (!e.Item.Parent.Visible)
                    e.Item.Parent.Visible = true;
            }

        }


This will ensure that you'll only show if you've bound a 'data' item (remember you're doing binding in the HeaderTemplate too).  You could also hook similar things into other events, but it's generally more convenient to put these things into events that relate to the actual control (pre_render's probably another good candidate as it will only get called once and you can check the count in the DataSource).


Technorati Profile
posted on Monday, March 16, 2009 10:28:27 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Wednesday, March 11, 2009

Congratulations, you've installed dasBlog with Web Deploy!

After logging in, be sure to visit all the options under Configuration in the Admin Menu Bar above. There are 26 themes to choose from, and you can also create your own.

 

posted on Wednesday, March 11, 2009 6:00:00 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Friday, February 13, 2009

Converting from scientific number format to decimal or string in C#

I'm a programmer, but there are a few things I'll admit I don't do much of (as I have little interest in learning).  Playing with numbers in scientific notation is one of them.

I was importing from a spreadsheet and needed to get "6.00234419836431E+15" to something readable.

I discovered that you need to specify a NumberStyle when you parse as a decimal, because by default you'll get an error as it expects an 'easy' conversion.

The number above had decimals, exponent, the lot - so the following line of code does the job nicely...


Console.WriteLine(decimal.Parse("6.00234419836431E+15", System.Globalization.NumberStyles.Any).ToString());
//Globalisation namespace just shown for clarity - you'll want to put this in a using statement :)


This gives you "6002344198364310". Sweet.

posted on Friday, February 13, 2009 4:39:34 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Thursday, February 05, 2009

Make JQuery and Prototpye coexist and play together with a GreaseMonkey User Script

I've been playing with Greasemonkey scripts recently - for Redbubble.com, and wanted to use JQuery with GreaseMonkey.  This is pretty well documented, but I discovered an incompatibility with my script and the host site, as it uses the Prototype Javascript library (must admit I didn't know much about it).

Prototype (like JQuery) uses the $ notation, and so by default any GreaseMonkey User Script loaded will hijack the $ object, meaning that stuff on the original site may stop working.

I thought I was sunk but it turns out JQuery just gets better, and it can gracefully give back control of the $ to whichever library originally loaded it.  Just call..

jQuery.noConflict();

You then have to use jQuery instead of $ (e.g. jQuery("#myID") instead of $("#myID") ), but hey - that's a small price to pay when the alternative is rewriting the whole thing long-hand.

posted on Thursday, February 05, 2009 9:14:44 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Wednesday, January 28, 2009

CommaDelimitedStringCollection - for when you want to write a comma delimited string from a collection !

Amazing that I still find BCL classes every day in .NET to do simple tasks.  I had a feeling that something may exist but didn't expect to find it in the System.Configuration namespace.

using System.Configuration;

CommaDelimitedStringCollection strings = new CommaDelimitedStringCollection();

foreach(string item in myOtherCollection)
{
    strings.Add(item);
}

//Spit out your comma separated string
string output = strings.ToString();

Simple!

posted on Wednesday, January 28, 2009 3:32:30 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [1]
# Monday, January 19, 2009

SANS Institute - Top 25 Dangerous Programming errors

This is really quite interesting.  A lot of stuff that's well known, but a good resource to go back to when you're designing a new system.  There's probably not a system I've ever seen that doesn't exhibit at least one of these in some minor way...

http://www.sans.org/top25errors/

posted on Monday, January 19, 2009 4:09:22 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]

The very reason I write in a blog

Some amusement today as I was trying to set up hibernation on my Windows XP box at work.  I was getting a strange error about 'not enough system resources to complete API'.  After a bit of mucking around I realised I'd actually encountered this very same error a while ago.

I actually used my own blog to fix a problem I'd had before and completely forgot about. 

Funny

posted on Monday, January 19, 2009 3:16:04 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]