Development – Leet 4 Life

Software Development Code Samples and More

Skip to: Content | Sidebar | Footer

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

Access Query String values with JavaScript

19 December, 2012 | JavaScript | By: Michael Adams

I was looking for a way to access query string values with javascript. I stumbled across a couple of articles that pointed me in the right direction, but unfortunately I forgot to bookmark them. I will try to find them again and provide a link to provide them the proper credit. In the meantime here is the implementation: This code parses through the URI components and uses a regular expression to pull out the name value pairs that are contained within and then returns it as a collection of the query strings and their values. This is one of the [Read More…]

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 Dynamic Height and Width

28 November, 2012 | jQuery | By: Michael Adams

I was working on a few pages where I wanted the content to automatically fill the height/width regardless of browser size. I set my DIV tag with a id of “Content” and then created the following JQuery automatically scale the DIV tag to the appropriate height and width. I only have one DIV tag that required dynamic height and width so I was able to just subtract the height and width of the other elements on the page. Replace N with the height/width of the other elements on the page. The JQuery: JQuery Break down: I use $(window).height() to get [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…]