Development – Leet 4 Life

Software Development Code Samples and More

Skip to: Content | Sidebar | Footer

Category: ASP.NET

Serializing NameValueCollection to JSON in ASP.NET MVC Web APIs

10 June, 2013 | ASP.NET, C#. NET | By: Michael Merrell

Recently I had the need to serialize a NameValueCollection object through MVC’s WebAPIs. However the inherit object that is provided in the Specialized Collections .NET Framework does not play nicely with JSON serialization. Because of this I ended up have to write my own set of custom classes for serializing NameValueCollection from JSON to be used inside the functionality of my Web APIs. This code is simple and gets the job done very well. Then the client side JavaScript: Read more about my problem of Serializing NameValueCollection to JSON using MVC Web API

HTML5 Canvas and ASP.NET Image Control

5 December, 2012 | ASP.NET, HTML5 | By: Michael Adams

I was playing with the HTML5 Canvas element trying to allow client side zooming/panning/rotating of an image. I finally figured out an implementation that will accommodate the zooming and I am still working on the panning/rotating pieces of the functionality. I use a SELECT element to act as the scale (Zoom) for the image. Even though it is not present in the code snippet below, I use a Generic Handler to populate my ASP.NET Image control. The HTML5 canvas uses the ASP.NET Image control as the source of the image and then I can use JavaScript and the Canvas element [Read More…]

JQuery And ASP.NET Gridview

21 November, 2012 | ASP.NET, jQuery | By: Michael Adams

I was in a situation where I was expanding the functionality of an existing ASP.NET Gridview and I needed to add on-click highlighting and double-click redirecting. I was browsing the JQuery website for a general idea on what to implement when I eventually pieced this together: The JQuery: In the click function I use JQuery to set a class that will change the row background and text color to help the user identify which row was selected. In the dblclick function I use JQuery to look up an id that is stored in a template column in the gridview. That [Read More…]

Displaying TIFF Images in ASP.NET

3 October, 2012 | ASP.NET, C#. NET | By: Michael Adams

I needed to display TIFF images that were stored in the database. Unfortunately it is not as simple as just setting the MIME Type and writing out the binary. The reason for this is because the TIFF image type is only supported in IE currently. So I asked Google and the overwhelming response I saw was to convert the TIFF into another image type and then write out the binary to the response stream. Here is my take on the solution: Written in C# (the image is sent via a Generic Handler hence the “context.Response”): It should be noted that [Read More…]

Firing JavaScript only when inside an ASP.NET Ajax Postback

29 June, 2012 | ASP.NET, C#. NET, jQuery | By: Michael Merrell

There are times where you need to fire a JavaScript event only when you are posting inside of an ASP.NET AJAX post back event. In my example below I am needing to fire a function used for a document ready jQuery event. This event only needs to be fired on AJAX post backs because on normal posts back it will already be handled by jQuery, however it will not be fired when executed inside of an AJAX post back unless told to. The following JavaScript is a pretty standard script for firing a set of functionality when a page has [Read More…]