My CodePad

Fewer words, more code!

jQuery: How to style Selects and <asp:dropdowns — January 7, 2014

jQuery: How to style Selects and <asp:dropdowns

There is a strange thing about select tags. Browsers do the styling and you have almost no power over it! You can change some colors and fonts but you can never make them beautiful (or in my case I can’t give the designer a chance to make them beautiful).
I searched for a while and found some approaches with pointer-events and divs but they aren’t a complete solution because they either aren’t cross-browser or you can’t style the options of the select.
Continue reading

JSON to C# objects — November 11, 2013

JSON to C# objects

.NET natively supports JSON through System.Web.Script.Serialization.JavaScriptSerializer.
In shorthand, it goes like this:

using System.Web.Script.Serialization;
var obj = new JavaScriptSerializer().Deserialize({YOUR JSON STRING});//String to Object

This, will de-serialize your JSON string to a generic object, but going from this to get a value well within the structure of a JSON string is quite messy:

Continue reading

JSON for all (almost!) — April 25, 2013