Lee Kelleher

Archive for posts tagged with 'snippet'

  1. How to use umbraco.library GetMedia in XSLT for Umbraco v4.5

    Posted on

    This is a quick follow-up on my previous blog post: “How to use umbraco.library GetMedia in XSLT“.  At the request of fellow Umbraco South-West UK developer, Dan, that I should update the code snippets for the new XML schema in Umbraco v4.5+ First a quick notice; if you are using v4.5.0, then please upgrade to v4.5.1, as there was a tiny bug in GetMedia that caused great confusion and headaches – you have been advised!…

    Tags: , , , ,

  2. How to use umbraco.library GetMedia in XSLT

    Posted on

    From time to time I notice a reoccurring post over at the Our Umbraco forum; how to display an image (from the Media section) in XSLT? A quick answer can be found on the Our Umbraco wiki for the umbraco.library GetMedia method. For most uses, the last example in the wiki works great.  But I want to show you a “super safe” way of dealing with GetMedia in XSLT. Where I find a lot of…

    Tags: , , , ,

  3. How to convert NameValueCollection to a (Query) String [Revised]

    Posted on

    Following on from a comment on my previous post about converting a NameValueCollection to a (query) string – I have finally got around to revising my code snippet.  Now the method will handle same key multiple values, (it no longer comma-separates them). I have also added extra parameters so that you can define your own delimiter (since the HTTP specification says that you can use both ampersands & and semicolons ;) and there is an…

    Tags: , , , , ,

  4. How to convert NameValueCollection to a (Query) String

    Posted on

    Most ASP.NET developers know that you can get a key/value pair string from the Request.QueryString object (via the .ToString() method). However that functionality isn't the same for a generic NameValueCollection object (of which Request.QueryString is derived from). So how do you take a NameValueCollection object and get a nicely formatted key/value pair string? (i.e. "key1=value1&key2=value2") ... Here's a method I wrote a while ago: /// <summary> /// Constructs a QueryString (string). /// Consider this method…

    Tags: , , , ,

  5. Making Request.QueryString writable (by clone/copy)

    Posted on

    Every now and then I completely forget that the Request.QueryString (and Request.Form) object is read-only. Today I had a bit of functionality where I needed to remove a key/value from the collection - but the Remove() method (of the NameValueCollection object) throws an exception. Unfortunately, the Request.QueryString's CopyTo method assigns the values to an ARRAY, not a NameValueCollection - losing functionality and flexibility. You need to copy the Request.QueryString object to a new NameValueCollection instance,…

    Tags: , , , ,

  6. Posting source code on WordPress.com

    Posted on

    I feel like a complete n00b … I’ve only just found out how to mark-up source-code snippets on WordPress.com It’s in their FAQs: How do I post source code? Essentially you use the short-code: [sourcecode language='css']...[/sourcecode] Here’s an example: // A "Hello World!" program in C# class Hello { static void Main() { System.Console.WriteLine("Hello World!"); } } I knew about WP.org plugins that did this, but I’ve been scratching my head on how do this…

    Tags: , , , ,