Showing posts from February, 2013

JavaScript runtime error: '$' is undefined

If you’re developing an MVC4 app and run into this error, you probably haven’t placed your scripts in the Script section. Looking at the _Layout.cshtml file, you’ll see one of the last lines is @RenderSection( "scripts" , required: false ) which will render a section titled scripts. The following is a sample: @section Scripts { <script type= "text/javascript" > $(function () { alert( "JQuery loaded and working!!" ); }); </script> } Here’s a link to the Gu man’s discussion of sections . Cost me about 3 hours. Hope it saves you a few!!!

First NuGet Public Package: States & Provinces

I recently had to code a drop down for a state field on an entry form. Didn’t take long and not a big pain but I thought, why is there no NuGet package for this. So,,,, First, states and provinces are generically termed political subregions or geographic subdivisions. There is an ISO standard so we’ll follow that. First thing we need is a representation of the subregion. /// <summary> /// Represents a political subregion such as a state or province. /// </summary> public class SubRegion { /// <summary> /// Gets or sets the name of the subregion. /// </summary> public string Name { get; set; } /// <summary> /// Gets or sets the ISO-3166 code for the subregion. /// </summary> public string IsoCode { get; set; } /// <summary> /// Gets or sets the standard abbreviation for the subregion. /// </summary> /// <remarks> /// For the US, this is the USPS 2 character a