<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Radu Enucă's Blog</title><link>https://weblogs.asp.net:443/raduenuca/</link><description>"By failing to prepare you are preparing to fail" - Benjamin Franklin</description><item><title>Pin My Friends Application (using Google Maps and Facebook APIs) – Part 3: Displaying the friends on the map</title><link>https://weblogs.asp.net:443/raduenuca/pin-my-friends-application-using-google-maps-and-facebook-apis-part-3-displaying-the-friends-on-the-map</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   &lt;ul&gt;     &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/11/12/pin-my-friends-application-using-google-maps-and-facebook-apis-part-1-introduction.aspx" target="_blank"&gt;Part 1 – Introduction&lt;/a&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/11/12/pin-my-friends-application-using-google-maps-and-facebook-apis-part-2-displaying-the-friends-list.aspx" target="_blank"&gt;Part 2 – Displaying the friends list&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt; &lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Part 3 – Displaying the friends on the map&lt;/font&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;This part will handle the displaying of the user’s friends as markers on the map:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.6 – Display makers on the map for each friend that has a location&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.7 – Display the friend profile when when the mouse hovers the marker&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;T&lt;font size="2"&gt;.8 – Handle the friends with no location&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h2 align="justify"&gt;T.6 – Display makers on the map for each friend that has a location&lt;/h2&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;In order to display a marker on the Google Map we need the Latitude and Longitude for the marker’s position. We can get the Latitude and Longitude in two ways:&lt;/font&gt;&lt;/div&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;Make and additional call to using the Facebook API to get more details about the location object.&amp;nbsp; By using the id of the location object we can get another object that has a location property with latitude and longitude &amp;lt;- easy but boring&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;Use the Google Geocoding API to get the latitude and longitude based on the location name property &amp;lt;- a little harder but we learn something new in the process. This option is better not just because is something different to learn but because the Geocoder will unify locations like these:&lt;/font&gt;&lt;/div&gt;          &lt;ul&gt;           &lt;li&gt;             &lt;div align="justify"&gt;&lt;font size="2"&gt;Bucharest, Romania&lt;/font&gt;&lt;/div&gt;           &lt;/li&gt;            &lt;li&gt;             &lt;div align="justify"&gt;&lt;font size="2"&gt;Bukarest, Bucharest, Romania&lt;/font&gt;&lt;/div&gt;           &lt;/li&gt;            &lt;li&gt;             &lt;div align="justify"&gt;&lt;font size="2"&gt;București&lt;/font&gt;&lt;/div&gt;           &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Before jumping in let’s think for a moment. We have lots of friends in the same location so instead of looping over the entire list of friends and Geocode each location it will be better if we group the friends by their location. In this way we can use the Geocoder to get the latitude and longitude for the unique address list (so my 86 friends will be grouped in 7 unique address groups + 1 for friends that don’t have any address specified). That’s a huge performance boost because the Geocoder if called in a loop will return OVER_QUERY_LIMIT unless the request aren’t timmed to ~1 second apart (that’s 7s down for 86s):&lt;/font&gt;         &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;         &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Group the friends by their location
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;uniqueLocations = {};
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;param = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'location'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
$.each(friends, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(!uniqueLocations[&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[param]])
        uniqueLocations[&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[param]] = [];
    uniqueLocations[&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[param]].push(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;);
});

&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Display the friends on the map
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;locationName &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;in &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;uniqueLocations) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(locationName != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Location N/A"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        (&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(location, friends) {
            setTimeout(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() { displayFriendsMarkers(location, friends) }, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1000&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;); 
            })(locationName, uniqueLocations[locationName]);
    }
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Now that we have the friends grouped by their location the next step is to implement the displayFriendsMarkers function:&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font color="#0000ff"&gt;//TODO: Proper error handling (what happens if geocoding fails?)&lt;/font&gt;
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;displayFriendsMarkers(locationName, friends) {
    &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Call the geocoder to get the latitude and longitude for the locationName
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;geocoder = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Geocoder();
    geocoder.geocode({ address: locationName }, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(results, status) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;(status == google.maps.GeocoderStatus.ZERO_RESULTS) {
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;return
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;(status != google.maps.GeocoderStatus.OK) {
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;//alert("We're having difficulties, could you please try again in a moment? " + locationName);
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;return
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; friends.length; i++) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;friend = friends[i];
            &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Set the result from of geocoding
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;friend.latlng = results[&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;].geometry.location;
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;//Display the marker
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;plotMarker(createMarkerOptions(friend));
        }
    });
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;At this point we have the latitude and longitude for each friend that has a location specified. We have now all the details we need to create a marker for each friend but first the option object&amp;nbsp; used to create the marker need to be initialized:&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;createMarkerOptions(friend) {

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;lat = friend.latlng.lat();
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;lng = friend.latlng.lng();

    &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Distribute the markers with identical locations 
    //Dangerous Voodoo magic- don't try this at home :)
    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;lat += parseFloat(((Math.floor(Math.random() * &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;200&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;99&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) / &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;5000&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).toString() + friend.id);
    lng += parseFloat(((Math.floor(Math.random() * &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;200&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;99&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) / &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;5000&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).toString() + friend.id);
    friend.latlng = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.LatLng(lat, lng);

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"M"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;google.maps.MarkerImage(
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="3" face="Consolas"&gt;"http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"F"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;google.maps.MarkerImage(
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="3" face="Consolas"&gt;"http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png"
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;google.maps.MarkerImage(
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="3" face="Consolas"&gt;"http://www.google.com/intl/en_us/mapfiles/ms/micons/yellow-dot.png"
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = {
        position: friend.latlng,
        icon: image,
        title: friend.name
    };

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;options;
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;

      &lt;blockquote&gt;
        &lt;p align="justify"&gt;&lt;font size="2"&gt;There are tow things happening here. One is related to the fact that for a particular location all friends will have the same latitude and longitude values so all the markers will stack up on each other. So I had to do a quick and dirty algorithm to spread the markers around the original position (it is visible at higher zoom levels). The second things deals with setting the marker icon depending on gender (male: blue, female: red, unspecified: yellow).&lt;/font&gt;&lt;/p&gt;
      &lt;/blockquote&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The plotMarker function is very simple at this point:&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;plotMarker(options) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;marker = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Marker({ map: map });
    marker.setOptions(options);
    markersArray.push(marker);

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;marker;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;

      &lt;div&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25203-1.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 3-1. Markers at the original zoom level&lt;/font&gt;&lt;/p&gt;
        &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25203-2.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 3-2. Markers at a higher zoom level&lt;/font&gt;&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;I’m not a very big fun of the default Google Map icons so let’s replace them with something that looks better. There is a nice map icons collection here:&lt;/font&gt;&lt;a href="http://mapicons.nicolasmollet.com/" target="_blank"&gt;&lt;font size="2"&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="http://mapicons.nicolasmollet.com/wp-content/themes/mapiconscollection/images/logo.gif"&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; and in combination with the &lt;/font&gt;&lt;a href="http://www.powerhut.co.uk/googlemaps/custom_markers.php" target="_blank"&gt;&lt;font size="2"&gt;Google Map Custom Marker Maker&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; we get the following:&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;createMarkerOptions(friend) {

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;lat = friend.latlng.lat();
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;lng = friend.latlng.lng();

    &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Distribute the markers with identical locations 
    //Dangeours Woodoo magic- don't try this at home :)
    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;lat += parseFloat(((Math.floor(Math.random() * &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;200&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;99&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) / &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;5000&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).toString() + friend.id);
    lng += parseFloat(((Math.floor(Math.random() * &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;200&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;99&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) / &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;5000&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).toString() + friend.id);
    friend.latlng = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.LatLng(lat, lng);

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;shadow = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.MarkerImage(
        &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Content/images/shadow.png'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Size(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;54&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;16&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
    );
    shape = {
        coord: [&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;30&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;3&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;5&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;6&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;7&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;8&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;9&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;10&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;11&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;12&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;13&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;14&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;15&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;16&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;17&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;18&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;19&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;20&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;21&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;22&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;23&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;24&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;25&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;26&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;27&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;28&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;29&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;30&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;30&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;24&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;32&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;23&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;33&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;22&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;34&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;21&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;35&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;20&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;36&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;11&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;36&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;10&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;35&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;9&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;34&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;8&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;33&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;7&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;32&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;31&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;30&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;29&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;28&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;27&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;26&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;25&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;24&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;23&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;22&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;21&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;20&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;19&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;18&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;17&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;16&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;15&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;14&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;13&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;12&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;11&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;10&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;9&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;8&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;7&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;6&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;5&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;3&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;30&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;],
        type: &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="3" face="Consolas"&gt;'poly'
    &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"M"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.MarkerImage(
            &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Content/images/male.png'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Size(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;32&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;16&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        );
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"F"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.MarkerImage(
            &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Content/images/female.png'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Size(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;32&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;16&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        );
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        image = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.MarkerImage(
            &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Content/images/unknown.png'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Size(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;32&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Point(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;16&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;37&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        );
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = {
        position: friend.latlng,
        icon: image,
        shadow: shadow,
        shape: shape,
        content: friend
    };

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;options;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;

      &lt;div&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25203-3.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 3-3. Markers at the original zoom level (new icons)&lt;/font&gt;&lt;/p&gt;
        &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25203-4.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 3-4. Markers at a higher zoom level (new icons). Notice that the position is different because we use random in the spreading algorithm&lt;/font&gt;&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;&lt;font size="2"&gt;T.7 – Display the friend profile when when the mouse hovers the marker&lt;/font&gt;&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;You may have noticed that in the last createMarkerOptions function version the title is gone from the options object and that content: friend is there. We’re going to reuse the template for displaying the friends list (with little modifications) to show the friend profile when the mouse is over the marker:&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;plotMarker(options) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;marker = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Marker({ map: map });
    marker.setOptions(options);
    markersArray.push(marker);
    google.maps.event.addListener(marker, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"mouseover"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//there is no way to get the marker position (screen coordinates) in v3
        //create a dummy overlay and get the position from its projection
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;helper = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.OverlayView();
        helper.setMap(map);
        helper.draw = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(!&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.ready) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.ready = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
                google.maps.event.trigger(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'ready'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            }
        };

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;pixelpos = helper.getProjection().fromLatLngToContainerPixel(marker.getPosition());
        showFriendProfile(marker.content, pixelpos.x, pixelpos.y);
    });

    google.maps.event.addListener(marker, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"mouseout"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
        hideFriendProfile();
    });

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;marker;
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;

      &lt;blockquote&gt;
        &lt;p align="justify"&gt;&lt;font size="2"&gt;One thing to note here is the hack that needs to be used to transform from world (map) to screen coordinates. This is something that I’ve picked up from the Google Maps API bug and feature requests site (see the References section)&amp;nbsp; &lt;/font&gt;&lt;/p&gt;
      &lt;/blockquote&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The showFriendProfile and hideFriendProfile functions&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;showFriendProfile(friend, x, y) {
    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'.friendContainer'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        .html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#friendTemplate'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).render(friend))
        .css(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'left'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, x)
        .css(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'top'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, y)
        .show();
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;hideFriendProfile() {
    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'.friendContainer'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;).hide();
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Some cleaning up functions&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);" align="justify"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;removeMarkers() {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;while &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(marker = markersArray.pop()) {
        marker.setMap(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    }
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;clearFriends() {
    removeMarkers();
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The result:&lt;/font&gt; &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25203-5.png"&gt; 

      &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 3-5. Friend profile showing on mouse over.&lt;/font&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;T&lt;font size="2"&gt;.8 – Handle the friends with no location&lt;/font&gt;&lt;/h2&gt;

&lt;div style="margin: 10px; padding: 5px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;
  
Well my time is up. The 36h of coding are gone and I have to admit that I’m a bit rusty. I was hopping to do more in this time: 

  &lt;ul&gt;
    &lt;li&gt;Handle the friends with no location (and the ones where geocoding fails). I had in mind a collapsible panel at the bottom of the screen with all name and pictures for all of them. Clicking a friend picture will give the user the opportunity to post a message to the friend wall and ask him/her to complete and address (or to correct the address) &lt;/li&gt;

    &lt;li&gt;Improve the performance by saving the friends data in the database and only add differences &lt;/li&gt;

    &lt;li&gt;Use the Facebook Real Time Updates and subscribe to modifications (for name, picture and location). Create an endpoint where Facebook can post the ID’s of modified friends. Then do a request and update the modifications in the database &lt;/li&gt;

    &lt;li&gt;Use WebSockets to show the modifications in real time if the user is connected &lt;/li&gt;
  &lt;/ul&gt;
I promise I will come back and create blog posts for each of the above.&lt;/div&gt;

&lt;h2&gt;&lt;font size="2"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://jibbering.com/faq/notes/closures/" target="_blank"&gt;Javascript Closures&lt;/a&gt; | &lt;a href="http://code.google.com/p/gmaps-api-issues/issues/detail?id=2342" target="_blank"&gt;Google Maps API bug and feature requests (Issue 2342)&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/h2&gt;

&lt;h2&gt;&lt;font size="2"&gt;Download&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/download/PinMyFriends.Solution.Part3.zip" target="_blank"&gt;Download Part 3 Code&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;&lt;/div&gt;</description><pubDate>Mon, 14 Nov 2011 02:44:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/pin-my-friends-application-using-google-maps-and-facebook-apis-part-3-displaying-the-friends-on-the-map</guid><category>ASP.NET MVC</category><category>Facebook SDK</category><category>Google Maps</category><category>jQuery</category><category>jQuery Templates</category></item><item><title>Pin My Friends Application (using Google Maps and Facebook APIs) – Part 2: Displaying the friends list</title><link>https://weblogs.asp.net:443/raduenuca/pin-my-friends-application-using-google-maps-and-facebook-apis-part-2-displaying-the-friends-list</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
 &lt;br&gt;&lt;/div&gt;

&lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;
  &lt;ul&gt;
    &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/11/12/pin-my-friends-application-using-google-maps-and-facebook-apis-part-1-introduction.aspx" target="_blank"&gt;Part 1 – Introduction&lt;/a&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;

    &lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000" size="3"&gt;&lt;strong&gt;Part 2 – Displaying the friends list&lt;/strong&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt; &lt;/li&gt;

    &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/11/14/pin-my-friends-application-using-google-maps-and-facebook-apis-part-3-displaying-the-friends-on-the-map.aspx" target="_blank"&gt;Part 3 – Displaying the friends on the map&lt;/a&gt; &lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt; 
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;This part will handle the displaying of the user’s friends:&lt;/font&gt;&lt;/p&gt;
  
&lt;ul&gt;   
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.4 – Grab the current user’s friends and display them in a list (no fancy paging just a dumb scrollable list)&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.5 – Upgrade the above list by displaying the friend location&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;
 &lt;/ul&gt;
  &lt;h2 align="justify"&gt;T.4 – Grab the current user’s friends and display them in a list (no fancy paging just a dumb scrollable list)&lt;/h2&gt;  
&lt;ol&gt;   
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;The friend profile will look very similar to the user profile and because there will be a lot of friends to show the best way to avoid messy code is to use a template engine. Because jQuery Templates are discontinued and soon to be replaced by jsRender the former will be used. Create a partial view called _FriendsList in the Views\Shared folder:&lt;/font&gt;         &lt;div style="background-color: rgb(0, 0, 0);"&gt;         
&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;src=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;font color="#a7f5f3"&gt;ht&lt;/font&gt;&lt;font color="#5fedea"&gt;tps://raw.github.com/BorisMoore/jsrender/master/jsrender.js&lt;/font&gt;"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"friendTemplate" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/html"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;li&amp;gt;
        &amp;lt;a href="{{=profile}}" target="_blank"&amp;gt;
            &amp;lt;img class="left profilePicture" src="{{=picture}}"  alt="Friend picture" title="{{=name}}" /&amp;gt;
            &amp;lt;div class="left"&amp;gt;
                &amp;lt;div class="profileName"&amp;gt;
                     {{=name}} ({{=gender}})
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/a&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"friendsList"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
      &lt;/div&gt;
      
&lt;blockquote&gt;
        
&lt;p align="justify"&gt;&lt;font size="2"&gt;The jsRender script is referenced directly from the github repository. The template is not so different from a jQuery Template version.&lt;/font&gt;&lt;/p&gt;
      &lt;/blockquote&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Render the partial in the _Layout.cshtml view: Just drop @Html.Partial(MVC.Shared.Views._FriendsList) after @RenderBody(). &lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add some styles in Site.css:&lt;/font&gt; 
      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        
&lt;pre class="code"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;/*Friends styling*/
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#friendsList
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;position&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;absolute&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;left&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;5px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;top&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;5px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;z-index&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;500&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;background-color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;transparent&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;display&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;none&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;90%&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;500px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;overflow&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;auto&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#friendsList ul
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;padding&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;list-style-type&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;none&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#friendsList li
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;64px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#friendsList a
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;display&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;block&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;10px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;text-decoration&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;none&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;background-color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;rgba(98,122,172,0.5)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;border-radius&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;10px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;64px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#friendsList a:hover
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;background-color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;rgba(51, 102, 153, 0.5)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add code in the facebook.js script file to get the friends from Facebook and render the friendTemplate:&lt;/font&gt; 
      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        
&lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;displayFriendsList() {
    FB.api(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/me/friends'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, { fields: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'name,id,gender' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;(!response || response.error) {
            &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//TODO: Display a proper error message
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;alert(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'An Error Occurred'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;friends = $.map(response.data, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(friend) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: friend.id,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'name'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: friend.name,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'picture'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'http://graph.facebook.com/' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ friend.id + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/picture'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'profile'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'http://www.facebook.com/' &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ friend.id,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'gender'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'male' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'M' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: (friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'female' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'F' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'N/A'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                };
            });
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;friendsList = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&amp;lt;ul&amp;gt;&amp;lt;/ul&amp;gt;'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            friendsList.html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#friendTemplate'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).render(friends));
            $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#friendsList'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html(friendsList).show();
        }
    });
}
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;clearFriendsLocation() {
    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#friendsList'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;);
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
      
&lt;blockquote&gt;
        
&lt;p align="justify"&gt;&lt;font size="2"&gt;The idea is very simple: Make a call to the Graph API asking the friends of the current user and also limit the fields to: id, name and gender (actually is not limiting&amp;nbsp; but extending because by default only id and name are returned). If everything is ok a new JSON object is returned and passed to the render function. A call to these two methods must be added in the showFacebookProfile and hideFacebookProfile functions.&lt;/font&gt;&lt;/p&gt;
      &lt;/blockquote&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The result:&lt;/font&gt;&lt;/div&gt;
    &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25202-1.png"&gt; 
    
&lt;p align="center"&gt;&lt;font size="1"&gt;Figure 2-1. Clicking on a friend in the list will open the Facebook profile&lt;/font&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;


&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;T.5 - Upgrade the above list by displaying the friend location&lt;/h2&gt;

&lt;ol&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Getting the location (from the current user or for a friend) requires additional permissions from the current user (user_location and friends_location). First step is to modify the Facebook application to require the permissions: &lt;/font&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25202-2.png"&gt; 
      
&lt;p align="center"&gt;&lt;font size="1"&gt;Figure 2-2. Edit the Pin My Friends application and go to Settings\Auth Dialog&lt;/font&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Modify the FB.login call to include the scope parameter: &lt;/font&gt;
      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        
&lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//user is not connected to your app or logged out
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;loginText.html(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Login with Facebook'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
loginButton.unbind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'click'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
loginButton.bind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'click'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    FB.login(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response.authResponse) {
            showFacebookProfile();
        }
    },
    { scope: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'user_location,friends_location' &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;});
});&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Modify the displayFriendsList function to request and show each friend location (also add addition code to the template):&lt;/font&gt; 
      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        
&lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;displayFriendsList() {
    FB.api(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/me/friends'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, { fields: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id,name,gender,location' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;(!response || response.error) {
            &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//TODO: Display a proper error message
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;alert(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'An Error Occurred'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;friends = $.map(response.data, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(friend) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;location;
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(!friend.location || friend.location.id == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;) {
                    location = &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="3" face="Consolas"&gt;'Location N/A'
                &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    location = friend.location.name;
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: friend.id,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'name'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: friend.name,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'picture'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'http://graph.facebook.com/' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ friend.id + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/picture'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'profile'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'http://www.facebook.com/' &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ friend.id,
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'gender'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'male' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'M' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: (friend.gender == &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'female' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'F' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'N/A'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
                    &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'location'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: location
                };
            });
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;friendsList = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&amp;lt;ul&amp;gt;&amp;lt;/ul&amp;gt;'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            friendsList.html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#friendTemplate'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).render(friends));
            $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#friendsList'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;).html(friendsList).show();
        }
    });
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The result: &lt;/font&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25202-3.png"&gt; 
      
&lt;p align="center"&gt;&lt;font size="1"&gt;Figure 2-3. Friends list with location&lt;/font&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;&lt;font size="2"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://code.google.com/intl/en-EN/apis/maps/documentation/javascript/" target="_blank"&gt;jsRender&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/h2&gt;
&lt;h2&gt;&lt;font size="2"&gt;Download&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/download/PinMyFriends.Solution.Part2.zip" target="_blank"&gt;Download Part 2 Code&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;&lt;/div&gt;</description><pubDate>Sat, 12 Nov 2011 13:41:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/pin-my-friends-application-using-google-maps-and-facebook-apis-part-2-displaying-the-friends-list</guid><category>ASP.NET MVC</category><category>Facebook SDK</category><category>Google Maps</category><category>jQuery</category></item><item><title>Pin My Friends Application (using Google Maps and Facebook APIs) – Part 1: Introduction</title><link>https://weblogs.asp.net:443/raduenuca/pin-my-friends-application-using-google-maps-and-facebook-apis-part-1-introduction</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   &lt;ul&gt;     &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font color="#ff0000" size="3"&gt;&lt;strong&gt;Part 1 – Introduction&lt;/strong&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/11/12/pin-my-friends-application-using-google-maps-and-facebook-apis-part-2-displaying-the-friends-list.aspx" target="_blank"&gt;Part 2 – Displaying the friends list&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt; &lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/11/14/pin-my-friends-application-using-google-maps-and-facebook-apis-part-3-displaying-the-friends-on-the-map.aspx" target="_blank"&gt;Part 3 – Displaying the friends on the map&lt;/a&gt; &lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;Because I’m on a business trip and I have some free time on my hands when I’m back in the hotel room, I have decided to join the &lt;/font&gt;&lt;a href="http://www.ubichallenge.ro/" target="_blank"&gt;&lt;font size="2"&gt;UbiChallenge&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; coding competition on the last 100m. The final submission date is 15th of November and I’m planning of finishing it in 36 hours including the blog posts (I’ve started this Friday 11.11.11 at 11:11:11 PM – well not right to the minute and second but the combination is nice, and plan to end it by Sunday 13.11 at 11 PM. I think that 12 hours of boring activities like eating, sleeping and some other stuff will be more than enough). Monday 14.11 I’ll probably spend a couple of hours reviewing and posting the solution. If someone wonders: I’m kind of frustrated because I’ve missed the &lt;a href="http://developer.yahoo.com/blogs/ydn/posts/2011/05/bragging-in-bucharest-openhackeu/" target="_blank"&gt;Yahoo! OpenHack EU&lt;/a&gt; from Bucharest this year so this is the perfect opportunity to create a HackDay for myself (not so much fun coding alone but….).&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;There are there coding problems in the competition and in order to participate one has to choose one of them: &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Multiplayer TicTacToe:&lt;/font&gt;         &lt;blockquote&gt;         &lt;p align="justify"&gt;&lt;font size="2"&gt;Implement and ASP.NET and HTML5 application that allows a user to play TicTacToe with other users. A user can open a new TicTacToe session and wait for other user to join the session or join an existing session. The user that opens the session will be the one starting the game and as in a normal TicTacToe game the opponent will move after and so on. The application should automatically inform the user when he’s turns comes and decide who the winner is (or if it is a even match).&lt;/font&gt;&lt;/p&gt;       &lt;/blockquote&gt;     &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Scratch Card&lt;/font&gt;         &lt;blockquote&gt;         &lt;p align="justify"&gt;&lt;font size="2"&gt;Implement a Scratch Card application (scratch and win). The UI must use jQuery and not Flash. The client side must call a web service (WCF) that generates a random code that can be winning or not. That code (with the form XXX-XXX-XXXX) must be saved in the database along with date / time of generation and its status (winner / loser). The system must be secure so no one could just call the web service in order create codes in the database. After scratching on the card there should be a message saying WINNER/LOSER and under it the generated code.&lt;/font&gt;&lt;/p&gt;       &lt;/blockquote&gt;     &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;My Friends Application&lt;/font&gt;         &lt;blockquote&gt;         &lt;p align="justify"&gt;&lt;font size="2"&gt;Implement and application called MyFriends that will any user to log in with his Facebook account; the application will read the location of all the user’s friends and then display on a map (Google Maps Mashup) their position, using blue dots for men and red for women. Mouse over a dot will display the friend’s Facebook picture.&lt;/font&gt;&lt;/p&gt;       &lt;/blockquote&gt;     &lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;There is nothing to complicated in either of them but the Google Maps + Facebook seems the most interesting by far so this is my pick (this and the fact that I’ve always wanted to do a blog post about Google Maps). The application name will be PinMyFriends (not very original but I don’t plan to sell it ).&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;So, let’s define the first tasks:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.1 - Setup solution and development environment:&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.2 - Display the Google Map&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;T.3 - Allow the user to login using Facebook and display user information (name and picture)&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h2 align="justify"&gt;T.1 – Setup solution and development environment&lt;/h2&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;We’ll be using Visual Studio 2010 SP1 for this project (the edition doesn’t really matter) and ASP.NET MVC3 (make sure you have ASP.NET MVC3 Tools Update installed):&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Start Visual Studio with administrative rights&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Create an empty solution called PinMyFriends.Solution&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Add an empty MVC3 project to the solution and name it PinMyFriends.UI&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Add or update the following NuGet packages:&lt;/font&gt;&lt;/div&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;EntityFramework 4.2&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;jQuery 1.7&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;jQuery.UI.Combined 1.8.16&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;jQuery.Validation 1.9&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;jQuery.vsdoc 1.6&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;Modernizr 2.0.6&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;T4MVC 2.6.64&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Create a GeneratedCode folder in the project and move T4MVC.tt and T4MVC.tt.settings.t4 there&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Add the HomeController and the Index view&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Double click the Properties folder in the Solution Explorer and click the Web tab&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;In the Servers section click Use Local IIS Web Server and enter http://localhost/PinMyFriends.UI in the Project Url (should be already there).&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Click Create Virtual Directory (this is the reason Visual Studio 2010 must be started with administrative privileges).&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Hit F5 and you should see the Index view&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt; &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-1.png" width="1289" height="702"&gt;   &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-1. This is how the project should look at this stage&lt;/font&gt;&lt;/p&gt;  &lt;h2 align="justify"&gt;T.2 – Display the Google Map&lt;/h2&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;In order to display a Google Map we need to do a few things:&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Reference the Google Maps APIs:&lt;/font&gt;         &lt;blockquote&gt;         &lt;p align="justify"&gt;&lt;font size="2"&gt;&amp;lt;script type="text/javascript" src="&lt;/font&gt;&lt;a href='http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script'&gt;&lt;font size="2"&gt;http://maps.google.com/maps/api/js?sensor=false"&amp;gt;&amp;lt;/script&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;&lt;/p&gt;       &lt;/blockquote&gt;     &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Add a the following div in the Index.cshtml:&lt;/font&gt;         &lt;div style="background-color: rgb(0, 0, 0);"&gt;         &lt;pre class="code"&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"map"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add the following styles in Site.css&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;html
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;100%&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;body
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;padding&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;100%&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#map
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;100%&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add the following JavaScript snippet in the Index.cshtml&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Setup the map
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;mapCenter = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.LatLng(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;mapOptions = {
            zoom: &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;3&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            center: mapCenter,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            mapTypeControl: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            keyboardShortcuts: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            streetViewControl: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            scrollwheel: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            scaleControl: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;,
            navigationControl: &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;false
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;};
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Show the map
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;map = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;google.maps.Map(document.getElementById(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"map"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;), mapOptions);
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
      &lt;/div&gt;

      &lt;blockquote&gt;
        &lt;p align="justify"&gt;&lt;font size="2"&gt;The map center and zoom level are set in order to have a good look at all continents. Also all map controls are removed and the map type is set to Roadmap. If everything is set correctly by pressing F5 the Index view should look like this:&lt;/font&gt;&lt;/p&gt;
      &lt;/blockquote&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-2.png" width="1289" height="702"&gt; 

&lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-2. Displaying the Google Map&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="2"&gt;T.3 - Allow the user to login using Facebook&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;In order to integrate our application with Facebook we first need to go to the Developers section in Facebook and create a new application there:&lt;/font&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Navigate to &lt;a href="https://developers.facebook.com/apps"&gt;https://developers.facebook.com/apps&lt;/a&gt; (requires Facebook account) and click Create New App:&lt;/font&gt;&lt;/div&gt;
    &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-3.png"&gt; 

    &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-3. Create application dialog&lt;/font&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Set the application’s basic information like below and write down the App Key and the App Secret:&lt;/font&gt;&lt;/div&gt;
    &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-4.png"&gt; 

    &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-4. Application's basic info page&lt;/font&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Click the Auth Dialog link under Settings and set the following (we will return to this screen later):&lt;/font&gt;&lt;/div&gt;
    &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-5.png"&gt; 

    &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-5. Customize the Authentication Dialog&lt;/font&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;There are several ways of integrating Facebook in the application. As there is no specific requirement for this competition I’ll use the &lt;a href="http://facebooksdk.codeplex.com/" target="_blank"&gt;Facebook C# SDK&lt;/a&gt; CodePlex project:&lt;/font&gt;&lt;/div&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;div align="justify"&gt;&lt;font size="2"&gt;Add the necessary NuGet packages&lt;/font&gt;&lt;/div&gt;
        &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-6.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-6. Quick access to NuGet packages.&lt;/font&gt;&lt;/p&gt;
        &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-7.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-7. NuGet packages to install.&lt;/font&gt;&lt;/p&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;div align="justify"&gt;&lt;font size="2"&gt;Set the AppID and App Secret in web.config&lt;/font&gt;&lt;/div&gt;
        &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-8.png"&gt; 

        &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-8. Web.config Facebook specific settings&lt;/font&gt;&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;A partial view called _FacebookInit.cshtml is added with the package. Some adjustments are needed:&lt;/font&gt; 

    &lt;div style="background-color: rgb(0, 0, 0);"&gt;
      &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"fb-root"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    window.fbAsyncInit = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
        FB.init({
            appId: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: yellow; color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Facebook&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;FacebookApplication&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Current&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AppId&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// App ID
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;channelURL: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: yellow; color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Request&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Scheme&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;://&lt;/span&gt;&lt;span style="background: yellow; color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Request&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Authority&lt;/span&gt;&lt;span style="background: yellow; color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Content(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"~/fbchannel.ashx"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Channel File
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;status: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// check login status
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cookie: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// enable cookies to allow the server to access the session
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;xfbml: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// enable OAuth 2.0
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;oauth: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true  &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;// parse XFBML
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;});

        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;// Run once with current status and whenever the status changes
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FB.getLoginStatus(updateButton);
        FB.Event.subscribe(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'auth.statusChange'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;, updateButton);
    };

    &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Load the Facebook SDK Asynchronously
    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(d) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;js, id = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'facebook-jssdk'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(d.getElementById(id)) { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        js = d.createElement(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'script'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;); js.id = id; js.async = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        js.src = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'//connect.facebook.net/en_US/all.js'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        d.getElementsByTagName(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'head'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)[&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].appendChild(js);
    } (document));  
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;blockquote&gt;
      &lt;p align="justify"&gt;&lt;font size="2"&gt;Because I’m not planning to go back to the server and then make a call to the Facebook API just to get the logged user name and picture I’ve removed the window.location.reload(); and replace it with a JavaScript function call.&lt;/font&gt;&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add a partial view called _UserProfile to the Views\Shared folder that will display the user picture, name and login status:&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        &lt;pre class="code"&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;src=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: yellow;"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Links&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Scripts&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;facebook_js"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;img &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"left" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"userPicture" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"profilePicture" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;src=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: yellow;"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Links&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;images&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;unknown_user_png" 
    &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;alt=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"User picture" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;title=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"User picture" &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"right"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"userName" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"profileName"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"facebook_login"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;a &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"fb_button fb_button_medium" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"facebook_login_button"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"fb_button_text"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;LogIn with Facebook&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;a&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add the necessary code to the _Layout.cshtml &lt;/font&gt;

      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        &lt;pre class="code"&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;DOCTYPE &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;html&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;html&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;head&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;meta &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;charset=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"utf-8" &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;title&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;link &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;rel=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"shortcut icon" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;href=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Links&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;images&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;favicon_ico"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;link &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;rel=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"stylesheet" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;href=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Links&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Site_css" &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;src=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Links&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Scripts&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;jquery_1_7_js"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;head&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;body&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"userProfile"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial(&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Shared&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_UserProfile)
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;RenderBody()
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial(&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Shared&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_FacebookInit)
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;body&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;html&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add new styles to Site.css &lt;/font&gt;

      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;body
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;100%&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;padding&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
}

&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;html&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#map
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;100%&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;#userProfile
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;position&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;absolute&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;right&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;5px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;top&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;5px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;z-index&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;500&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;background-color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;rgba(98,122,172,0.5)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;border-radius&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;10px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;64px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;.profilePicture
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;border-radius&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;10px 0 0 10px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;border&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;64px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;64px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;.profileName
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;font-size&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;22px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;#fff&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;font-weight&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;700&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;height&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;20px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;5px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;.left
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;float&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;left&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;.right
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;float&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;right&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}

&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="3" face="Consolas"&gt;.facebook_login
&lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;margin&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;10px 5px 5px&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;;
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Add a new script file called facebook.js&lt;/font&gt; 

      &lt;div style="background-color: rgb(0, 0, 0);"&gt;
        &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="3" face="Consolas"&gt;function &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;updateButton(response) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;loginButton = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#facebook_login_button'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;loginText = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#facebook_login_button span'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;(response.authResponse) {
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;//The User is already logged in and connected
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;showFacebookProfile();
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Change login button text
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;loginText.html(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Logout from Facebook'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        loginButton.unbind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'click'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        loginButton.bind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'click'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            hideFacebookProfile();
        });
    } &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;{
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//user is not connected to your app or logged out
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;loginText.html(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Login with Facebook'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        loginButton.unbind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'click'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        loginButton.bind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'click'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            FB.login(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response.authResponse) {
                    showFacebookProfile();
                }
            }&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        });
    }
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;showFacebookProfile() {
    FB.api(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/me'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userPicture = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#userPicture'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userName = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#userName'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;);
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Show the picture
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userPictureSrc = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'http://graph.facebook.com/' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ response.id + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/picture'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        userPicture.prop(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'src'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;, userPictureSrc);
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="3" face="Consolas"&gt;//Show the name
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userName.html(response.name);
    });
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;hideFacebookProfile() {
    FB.logout(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(response) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userPicture = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#userPicture'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userName = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#userName'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;);
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Show unknown user picture
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userPictureSrc = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Content/images/unknown_user.png'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        userPicture.prop(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'src'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;, userPictureSrc);
        &lt;/font&gt;&lt;/span&gt;&lt;font face="Consolas"&gt;&lt;font size="3"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Clear the user name
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;userName.html(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="3" face="Consolas"&gt;);
    });
}&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The result:&lt;/font&gt; &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-9.png"&gt; 

      &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-9. No logged in user display&lt;/font&gt;&lt;/p&gt;
      &lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/PinMyFriends/Figure%25201-10.png"&gt; 

      &lt;p align="center"&gt;&lt;font size="1"&gt;Figure 1-10. Logged in user display&lt;/font&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;



&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="2"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://code.google.com/intl/en-EN/apis/maps/documentation/javascript/" target="_blank"&gt;Google Maps JavaScript API V3&lt;/a&gt; | &lt;a href="http://developers.facebook.com/" target="_blank"&gt;facebook DEVELOPERS&lt;/a&gt; | &lt;a href="http://facebooksdk.codeplex.com/" target="_blank"&gt;Facebook C# SDK&lt;/a&gt; | &lt;a href="http://facebooksdk.codeplex.com/wikipage?title=Getting%20Started%20with%20an%20ASP.NET%20MVC%203%20Website%20%28With%20Javascript%20SDK%29&amp;amp;referringTitle=Documentation" target="_blank"&gt;Getting Started with an ASP.NET MVC 3 Website (With Javascript SDK)&lt;/a&gt; &lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/h2&gt;

&lt;h2&gt;&lt;font size="2"&gt;Download&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/download/PinMyFriends.Solution.Part1.zip" target="_blank"&gt;Download Part 1 Code&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;&lt;/div&gt;</description><pubDate>Sat, 12 Nov 2011 03:29:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/pin-my-friends-application-using-google-maps-and-facebook-apis-part-1-introduction</guid><category>ASP.NET MVC</category><category>Facebook SDK</category><category>Google Maps</category><category>jQuery</category></item><item><title>ASP.NET MVC–Prevent an action method from being called before another action</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-prevent-an-action-method-being-called-before-another-action</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h2 align="justify"&gt;&lt;font size="3"&gt;Problem&lt;/font&gt;&lt;/h2&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;You want to restrict access by callers to an action method unless another action method was called first.&lt;/font&gt;&lt;/p&gt;  &lt;h2 align="justify"&gt;&lt;font size="3"&gt;Solution&lt;/font&gt;&lt;/h2&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;There is already a similar functionality implemented by the Authorize attribute. The Authorize attribute is an authorization filter restricts the access to an action method to users who are both authenticated and authorized. If the user is not authenticated and authorized the Authorized attribute will set a HTTP status code of 401 Unauthorized to the response. This will get picked up by the Forms Authentication HTTP Module who will perform a redirection to the log in action. The Authorize attribute extends the FilterAttribute abstract class and implements the IAuthorizationFilter interface and so will our filter (let’s call it ActionInitializationRequired). With some help from the MVC3 source code we will have the following template to start with:&lt;/font&gt;&lt;/p&gt;  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AttributeUsage&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AttributeTargets&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Method , Inherited &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, AllowMultiple &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionInitializationRequiredAttribute &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;FilterAttribute &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;&lt;font size="2"&gt;IAuthorizationFilter
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;protected virtual bool &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AuthorizeCore( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpContextBase &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;httpContext )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( httpContext &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;throw new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ArgumentNullException&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"httpContext" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        }

        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//TODO: Add code to check that another action was called first

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private void &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CacheValidateHandler(
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpContext &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;context ,
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;object &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;data ,
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;ref &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpValidationStatus &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;validationStatus
        )
    {
        validationStatus &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;OnCacheAuthorization( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpContextWrapper&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( context ) );
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual void &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;OnAuthorization( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AuthorizationContext &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( filterContext &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;throw new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ArgumentNullException&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"filterContext" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;OutputCacheAttribute&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsChildActionCacheActive( filterContext ) )
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;throw new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;InvalidOperationException&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;(
                &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"ActionInitializationRequiredAttribute cannot be used within a child action caching block."
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( AuthorizeCore( filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HttpContext ) )
        {
            &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpCachePolicyBase &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cachePolicy &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HttpContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Response&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cache;
            cachePolicy&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SetProxyMaxAge( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TimeSpan&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) );
            cachePolicy&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AddValidationCallback( CacheValidateHandler , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;/* data */&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        }
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            HandleUnauthorizedRequest( filterContext );
        }
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;protected virtual void &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HandleUnauthorizedRequest( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AuthorizationContext &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;filterContext )
    {
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//TODO: Add code to respond to the case when the initialization action wasn't called
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;protected virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpValidationStatus &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;OnCacheAuthorization( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpContextBase &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;httpContext )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( httpContext &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;throw new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ArgumentNullException&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"httpContext" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;bool &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;isAuthorized &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AuthorizeCore( httpContext );
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( isAuthorized ) &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpValidationStatus&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Valid : &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpValidationStatus&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;IgnoreThisRequest;
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We have 2 TODO lines:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;font size="2"&gt;&lt;font face="Arial"&gt;Add code to check that another action was called first&lt;/font&gt; &lt;/font&gt;&lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;&lt;font face="Arial"&gt;Add code to respond to the case when the initialization action wasn't called&lt;/font&gt; &lt;/font&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;font size="2"&gt;Let’s solve them one by one:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2" face="Arial"&gt;1. Add code to check that another action was called first&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;The first thing we need to do is find a way to know when an action was called. For this we can add some code in the action itself or use a more AOP approach by creating an Action Filter and overriding the OnActionExecuted method (this method is Called by the MVC framework after the action method executes). Let’s call this action filter ActionInitializer:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AttributeUsage&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AttributeTargets&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Method , Inherited &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, AllowMultiple &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionInitializerAttribute &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;ActionFilterAttribute
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public override void  &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;OnActionExecuted( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionExecutedContext &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;area &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;RouteData&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DataTokens[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"area" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Empty;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;action &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ActionDescriptor&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ActionName;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;controller &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ActionDescriptor&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ControllerDescriptor&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ControllerName;

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;actionInitializerKey &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= 
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Format( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"{0}/{1}/{2}" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, area&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( ) , controller , action );

        filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HttpContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Session&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( actionInitializerKey , actionInitializerKey );

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;base&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;OnActionExecuted( filterContext );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This filter does a very simple thing. It gets the name of area, the name of the controller and the name of the action it is applied on and save them in Session in a area/controller/action format. This is a very basic way of stating that the action was executed. Let’s get back to the TODO number one above&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;In order to know what to look up in the Session object we need a way to tell the ActionInitializationRequired filter what action is responsible for initialization. For this we will the following properties:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;private string &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_area;
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private string &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_controller;
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private string &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_action;

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Area
{
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;get
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_area &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;String&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Empty;
    }
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;set
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        _area &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;value&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    }
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Controller
{
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;get
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_controller &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Home"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
    }
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;set
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        _controller &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;value&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    }
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Action
{
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;get
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_action &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
    }
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;set
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        _action &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;value&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    }
}

&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private string &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;ActionKey
{
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;get
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Format( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"{0}/{1}/{2}" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Area , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Controller , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Action );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;these properties (with the exception of the ActionKey property that is just a helper) will become Named Parameters for our authorization filter. Now we have everything we need to replace the first TODO line:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( httpContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Session[ &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ActionKey ] &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;font face="Arial"&gt;2. Add code to respond to the case when the initialization action wasn't called&lt;/font&gt; &lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;For this we will follow a similar approach like the Authorize attribute and return a HTTP status code but instead of 401 Unauthorized we will return 403 Forbidden (we can also return a custom code and build a HTTP module that knows how to handle responses with that particular code, just like the FormsAuthentication module does but we will keep this simple). Before returning 403 let’s take a little detour and build a new ActionResult (or a new HttpStatusCodeResult because we will extend this class instead of ActionResult):&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpForbiddenResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;HttpStatusCodeResult
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;{
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// HTTP 403 is the status code for Forbidden
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private const int &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ForbiddenCode &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;403&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HttpForbiddenResult( )
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) { }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HttpForbiddenResult( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;statusDescription )
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;base&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;( ForbiddenCode , statusDescription ) { }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This is not needed because we can use the HttpStatusCodeResult directly but it makes our code to look good. The replacement for the second TODO line is:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Returns HTTP 403 
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filterContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Result &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpForbiddenResult&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;( );&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;and this is it. Let’s assume the following:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;We have a controller named Home in the root area&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;We have an action called Initializer to which we will apply the ActionInitializer attribute&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;We have an action called RequiresInitialization to which we will apply the ActionInitializationRequired attribute&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This is how we use the attributes:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HomeController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( );
    }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionInitializer&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Initializer( )
    {
        TempData[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"InitCalled" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Action initializer called !!!"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;RedirectToAction( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionInitializationRequired&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Action &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Initializer" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;RequiresInitialization( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;View( );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The Index view looks like this:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@{
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;}

&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;h2&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Index&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;h2&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;

&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ActionLink( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Call Action Initializer" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Initializer" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) | 
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ActionLink( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Call Action that requires initialization" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"RequiresInitialization" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)

&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;br &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;

&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( TempData[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"InitCalled" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
{ 
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TempData[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"InitCalled" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( )&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/h2&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;How it works&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The inner workings are pretty simple:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;An action filter add a key into the Session object after the action has executed.&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;An authorization filter checks the Session for that particular key and allows the execution of the action is applied on. If the key is not found then a 403 Forbidden HTTP status code is returned.&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;With the actual implementation we can only perform a one time initialization, that is if we call the initialization action we can call all the action that require initialization for the life time of the session. With a small modification we can have both one time and every time initializations (we cannot call an action that requires authorization more than once. If another call is needed the initialization action needs to be called again) but this is a subject for another post.&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/Blog-ActionInitializer/" target="_blank"&gt;Action Initializer Demo&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;



&lt;p align="left"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;References&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;a href="http://forums.asp.net/p/1648260/4282212.aspx/1?Re+How+to+detect+if+correct+post+called+an+url" target="_blank"&gt;Original post about the subject&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx" target="_blank"&gt;Authorize Attribute&lt;/a&gt;&lt;/font&gt; | &lt;a href="http://aspnet.codeplex.com/SourceControl/list/changesets" target="_blank"&gt;MVC3 Source Code&lt;/a&gt; | &lt;a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming" target="_blank"&gt;Aspect-oriented programming (AOP)&lt;/a&gt;&lt;/p&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;

  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 15 May 2011 12:27:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-prevent-an-action-method-being-called-before-another-action</guid><category>ASP.NET MVC</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 6: Creating a jQuery Cascade Plugin</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   &lt;ul&gt;     &lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part 1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;      &lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         &lt;ul&gt;         &lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;          &lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;          &lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;       &lt;/ul&gt;     &lt;/li&gt;      &lt;li&gt;&lt;font color="#ff0000" size="3"&gt;&lt;strong&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/strong&gt;&lt;/font&gt; &lt;/li&gt;   &lt;/ul&gt; &lt;/div&gt;  &lt;h1&gt;Part 6: Creating a jQuery Cascade Plugin&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;If we take a closer look at Part 5 we will see that there is to much repetition in the java script code (for example for each additional dropdown list we need to add a callback for the change event). Not to mention the code gets bigger and bigger with each dropdown list we add (even for the simplified version that uses jQuery Templates). So the next natural move will be to encapsulate all the code inside a jQuery Cascade Select Plugin.&lt;/font&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;font size="2"&gt;In this post we will only define a template for the plugin which we will expand in the following posts. According to &lt;a href="http://docs.jquery.com/Plugin" target="_blank"&gt;Plugins/Authoring&lt;/a&gt; tutorial we should start with:&lt;/font&gt;&lt;/p&gt;  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;($) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods = {
        init: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
                &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//The selector will probably return more than one element
                //Init the plugin for each element here
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;});
        }
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//Other Methods here
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}

    $.fn.cascadeSelect = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(method) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(methods[method]) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[method].apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Array.prototype.slice.call(arguments, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;typeof &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;method === &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'object' &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;|| !method) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods.init.apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, arguments);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            $.error(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Method ' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ method + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;' does not exist on jQuery.cascadeSelect'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        }
    };
})(jQuery);&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;There are two approaches for building the plugin:&lt;/font&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Specify which element is the root and set the children of each element that will perform cascades&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Specify the parent to each element that will participate in the cascade. The element with no parent is the root element&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The second method is the most flexible as will allow us to bind the child to any parent event (not only ‘change’) and this will be the option for a general purpose cascade plugin (maybe in a future post). For out specific task, cascade dropdown lists the first option is better because we only need the ‘change’ event.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We have identified the first option we need to set: &lt;strong&gt;root&lt;/strong&gt;, and because there is only one root the default value for the root option will be &lt;strong&gt;false&lt;/strong&gt; (meaning that we will explicitly set the root element).&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Looking again at part 5 we can see that for each element participating in the cascade we need the &lt;strong&gt;url &lt;/strong&gt;from which we will load the content. There is no default value for this option. Next we need to specify the child/children of the current element (the children will be loaded when the current element’s selection changes) so we need a &lt;strong&gt;childSelector&lt;/strong&gt; option.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We also need to show a text that will prompt the user to select an item ( &lt;strong&gt;promptText &lt;/strong&gt;with the default value ‘[Please select an item]’ ) and a text to show when there is no information to be shown ( &lt;strong&gt;noInfoText &lt;/strong&gt;with the default value ‘No information available’).&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The plugin looks like this now:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;($) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods = {
        init: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
                &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//The selector will probably return more than one element
                //Init the plugin for each element here
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;});
        }
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//Other Methods here
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}

    $.fn.cascadeSelect = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(method) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(methods[method]) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[method].apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Array.prototype.slice.call(arguments, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;typeof &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;method === &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'object' &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;|| !method) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods.init.apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, arguments);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            $.error(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Method ' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ method + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;' does not exist on jQuery.cascadeSelect'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }
    };

    $.fn.cascadeSelect.defaults = {
        root: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        url: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        childSelector: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        promptText: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select an item]'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,
        noInfoText: &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'No information available'
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;};
})(jQuery);&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Now it’s time to implement the “init” method:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;init: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// setup private variables
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$this = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);

        options = $.extend({}, $.fn.cascadeSelect.defaults, options);

        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Save the options
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$this.data(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'options'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, options);

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.promptText) {
            setPromptText($this);
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.noInfoText) {
            setNoInfoText($this);
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.root) {
            methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'load'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call($this);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            toggleNoInfoText($this, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.childSelector != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;) {
            onChange($this);
        }
    });
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;First we initialize the $this variables and we merge the options (provided from the plugin consumer) with the default options. Because we need to read the options at a later time we use the jQuery data() function to associate the options data with the element.&lt;/p&gt;

&lt;p align="justify"&gt;Next are a series of checks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;We set the promptText if one exists (the plugin consumer can set it to null even if we have a default)&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;We set the noInfoText if one exists&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;If the element it is a root element we need to load it first so we all the “load” method. If the element is a child element we toggle the NoInfoText (there is no parent element selected yet).&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;If the element has childs then we bind to the “change” event.&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;As we can see in the list above there are a lot of new private functions to be added and a public one (“load”). The load function will perform an Ajax call to the url set in the parameters and will also introduce two new parameters, one called filter and one call onLoad:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;The filter parameter will be null by default (for example we load all Continents) and will have a value when we want to filter the results (for the Countries dropdown list the value of the filter parameter will be “continentId” and the value to be filtered will be passed when the Continents’ dropdown lists value changes).&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;The onLoad parameter will override the Load function with a custom function passed in from the “client”. This is useful because the Load function only knows how to fill dropdown lists but we want to show the cities in a table.&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;The plugin looks like this now:&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;($) {
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Return the options stored for this element
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;getOptions = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = element.data(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'options'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options;
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            $.error(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'The element must be initialized first'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        }
    }

    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Set the promt text that will appear as the first value
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;setPromptText = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;defaultValue = getOptions(element).promptText;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;option = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Option(defaultValue, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        element.append(option);
    }

    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Set the text that will appear if there is no data to display
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;setNoInfoText = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfoElement = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ element.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;)).append(options.noInfoText);

        element.parent().append(noInfoElement);
    }

    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Toggle the noInfoText
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;toggleNoInfoText = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element, visible) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfoElement = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ element.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(visible) {
            noInfoElement.show();
            element.hide();
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            noInfoElement.hide();
            element.show();
        }

        $(options.childSelector).each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;child = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfoChildElement = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ child.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));

            noInfoChildElement.show();
            child.hide();
        });
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;onChange = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        element.bind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;options = getOptions(element);
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Iterate the childs
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(options.childSelector).each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;child = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Clear the child of its elements
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'clear'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call(child);

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element.val() != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'load'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call(child, element.val());
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    toggleNoInfoText(child, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                }
            });
        });
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods = {
        init: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// setup private variables
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$this = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);

                options = $.extend({}, $.fn.cascadeSelect.defaults, options);

                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Save the options
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$this.data(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'options'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, options);

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.promptText) {
                    setPromptText($this);
                }

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.noInfoText) {
                    setNoInfoText($this);
                }

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.root) {
                    methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'load'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call($this);
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    toggleNoInfoText($this, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                }

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.childSelector != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    onChange($this);
                }
            });
        },
        load: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;element = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;url = options.url;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filter = options.filter;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;json = {};

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(filter != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                json[filter] = data;
            }

            data = data || &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;onLoadCallback = options.onLoad;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(onLoadCallback &amp;amp;&amp;amp; $.isFunction(onLoadCallback)) {
                onLoadCallback.call(element, json);
            }
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                $.ajax({
                    url: url,
                    type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    data: json,
                    dataType: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'JSON'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;(data) {
                        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// because $('#id') != document.getElementById('id')
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domElement = element.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);

                        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Emtpy the dropdown list
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domElement.options.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
                            domElement.remove(i);
                        }

                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data.length &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; data.length; i++) {
                                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item = data[i];
                                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;option = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Option(item.Name, item.Id);
                                element.append(option);
                            }
                            toggleNoInfoText(element, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        }
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                            toggleNoInfoText(element, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        }
                    }
                });
            }
        }
    }

    $.fn.cascadeSelect = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(method) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(methods[method]) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[method].apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Array.prototype.slice.call(arguments, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;typeof &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;method === &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'object' &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;|| !method) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods.init.apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, arguments);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            $.error(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Method ' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ method + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;' does not exist on jQuery.cascadeSelect'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }
    };

    $.fn.cascadeSelect.defaults = {
        root: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        url: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        childSelector: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        promptText: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select an item]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        noInfoText: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'No information available'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        filter: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,
        onLoad: &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;null
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;};
})(jQuery);
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;There is nothing complicated about getOptions, setPromptText, setNoInfoText and toggleNoInfoText so let’s move to the onChange function.&amp;nbsp; The onChange function binds some code the change event to the current element. When the change events happens&amp;nbsp; we call the Clear function on each child and then call the Load function passing the selected item in case we selected an item and not the [Please select and item]. The Load function is very similar to what we’ve used in Part 5.1 with the exception of the callback onLoad function that overrides the default behavior.&lt;/p&gt;

&lt;p align="justify"&gt;There are two new additions, the Clear public function and the onClear parameter used to override the default behavior of the Clear function when the element is not a dropdown list. The final look of the plugin is:&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;($) {
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Return the options stored for this element
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;getOptions = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = element.data(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'options'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options;
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            $.error(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'The element must be initialized first'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        }
    }

    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Set the promt text that will appear as the first value
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;setPromptText = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;defaultValue = getOptions(element).promptText;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;option = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Option(defaultValue, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
        element.append(option);
    }

    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Set the text that will appear if there is no data to display
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;setNoInfoText = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfoElement = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ element.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;)).append(options.noInfoText);

        element.parent().append(noInfoElement);
    }

    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Toggle the noInfoText
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;toggleNoInfoText = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element, visible) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfoElement = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ element.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(visible) {
            noInfoElement.show();
            element.hide();
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            noInfoElement.hide();
            element.show();
        }

        $(options.childSelector).each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;child = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfoChildElement = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ child.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));

            noInfoChildElement.show();
            child.hide();
        });
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;onChange = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element) {
        element.bind(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;options = getOptions(element);
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Iterate the childs
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(options.childSelector).each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;child = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Clear the child of its elements
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'clear'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call(child);

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(element.val() != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'load'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call(child, element.val());
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    toggleNoInfoText(child, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                }
            });
        });
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods = {
        init: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// setup private variables
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$this = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);

                options = $.extend({}, $.fn.cascadeSelect.defaults, options);

                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Save the options
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$this.data(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'options'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, options);

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.promptText) {
                    setPromptText($this);
                }

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.noInfoText) {
                    setNoInfoText($this);
                }

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.root) {
                    methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'load'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call($this);
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    toggleNoInfoText($this, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                }

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.childSelector != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    onChange($this);
                }
            });
        },
        clear: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;element = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;onClearCallback = options.onClear;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(onClearCallback &amp;amp;&amp;amp; $.isFunction(onClearCallback)) {
                onClearCallback.call(element);
            }
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(options.noInfoText) {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domElement = element.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domElement.options.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
                        domElement.remove(i);
                    }
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;{
                    element.empty();
                }

                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Call clear on the childs as well
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(options.childSelector).each(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;child = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);
                    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Clear the child of its elements
                    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'clear'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;].call(child);
                });
            }
        },
        load: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;element = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;options = getOptions(element);

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;url = options.url;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;filter = options.filter;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;json = {};

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(filter != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                json[filter] = data;
            }

            data = data || &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;onLoadCallback = options.onLoad;
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(onLoadCallback &amp;amp;&amp;amp; $.isFunction(onLoadCallback)) {
                onLoadCallback.call(element, json);
            }
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                $.ajax({
                    url: url,
                    type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    data: json,
                    dataType: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'JSON'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;(data) {
                        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// because $('#id') != document.getElementById('id')
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domElement = element.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;);

                        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Emtpy the dropdown list
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domElement.options.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
                            domElement.remove(i);
                        }

                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data.length &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; data.length; i++) {
                                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item = data[i];
                                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;option = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Option(item.Name, item.Id);
                                element.append(option);
                            }
                            toggleNoInfoText(element, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        }
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                            toggleNoInfoText(element, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        }
                    }
                });
            }
        }
    };

    $.fn.cascadeSelect = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(method) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(methods[method]) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods[method].apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Array.prototype.slice.call(arguments, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;typeof &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;method === &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'object' &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;|| !method) {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;methods.init.apply(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, arguments);
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            $.error(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'Method ' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ method + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;' does not exist on jQuery.cascadeSelect'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        }
    };

    $.fn.cascadeSelect.defaults = {
        root: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        url: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        childSelector: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        promptText: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select an item]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        noInfoText: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'No information available'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        filter: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        onLoad: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,
        onClear: &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;null
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;};
})(jQuery);&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;and this is how to use it:&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'continents'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'countries'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Cities&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'cities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                Name
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                Population
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;

&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'text/javascript'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).cascadeSelect({
            root: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'/&lt;/span&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;CascadingDropDownLists&lt;/font&gt;&lt;font color="#f79646"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;DropDownjQueryAjaxPost&lt;/font&gt;&lt;font color="#f79646"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;GetContinents&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            promptText: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select a continent]'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//promptText: null,
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;childSelector: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'#countries'
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;});

        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).cascadeSelect({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;a&gt;'&lt;/a&gt;&lt;/span&gt;&lt;a&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;/&lt;/span&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;CascadingDropDownLists&lt;/font&gt;&lt;font color="#f79646"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;DropDownjQueryAjaxPost&lt;/font&gt;&lt;font color="#f79646"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;GetCountries&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;/a&gt;&lt;/font&gt;&lt;a&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
&lt;/span&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;            promptText: &lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select a country]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            filter: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"continentId"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,
            childSelector: &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'#cities'
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;});

        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#cities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).cascadeSelect({
            promptText: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            filter: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countryId"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            onLoad: loadCities,
            onClear: clearCities
        });
    });

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;clearCities() {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domCities = cities.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domCities.rows.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
            domCities.deleteRow(i);
        }
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;loadCities(data) {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities = $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domCities = cities.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfo = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfo_' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ cities.attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'id'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));

        $.ajax({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;/&lt;/span&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;CascadingDropDownLists&lt;/font&gt;&lt;font color="#f79646"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;DropDownjQueryAjaxPost&lt;/font&gt;&lt;font color="#f79646"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#f79646"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font color="#f79646"&gt;GetCities&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            data: data,
            type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data.length &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; data.length; i++) {
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item = data[i];

                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;lastRow = domCities.rows.length;
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityRow = domCities.insertRow(lastRow);

                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityName = cityRow.insertCell(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        cityName.innerHTML = item.Name;

                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityPopulation = cityRow.insertCell(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        cityPopulation.innerHTML = item.Population.toString();
                        cityPopulation.align = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'right'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
                    }
                    noInfo.hide();
                    cities.show();
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    noInfo.show();
                    cities.hide();
                }
            }
        });
    }
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt; 
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownjQueryAjaxPost/CascadePlugin" target="_blank"&gt;Cascading Dropdown Lists - jQuery Cascade Plugin&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="left"&gt;
  &lt;p align="left"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;strong&gt;&lt;font size="3"&gt;&lt;strong&gt;Download&lt;/strong&gt; &lt;/font&gt;&lt;/strong&gt;

&lt;div id="tabs-6"&gt;
  &lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;&amp;nbsp;&lt;/div&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;

  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 08 May 2011 07:54:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin</guid><category>ASP.NET MVC</category><category>Html Helper</category><category>jQuery</category></item><item><title>ASP.NET MVC–Display visual hints for the fields in your form</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-display-visual-hints-for-the-fields-in-your-form</link><description>&lt;div&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt;  &lt;div&gt;&lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;h2&gt;Problem&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;font size="2"&gt;You want to display additional information near a form field in order to help the users complete de form.&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;font size="2"&gt;You want the information to be visible only when the field has focus.&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Context&lt;/h2&gt;  &lt;p&gt;&lt;font size="2"&gt;We will use the following model:&lt;/font&gt;&lt;/p&gt;  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;public class &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;RegisterModel
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Required&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"You must specify a username." &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Display&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(
        Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"User name" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        Description &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"Choose something unique so others will know which contributions are yours."
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;UserName { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Required&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"You must specify an email address." &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DataType&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DataType&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EmailAddress )]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Display&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(
        Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Email address" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        Description &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Your email will not be public. It is required to verify your registration and for " &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&lt;font size="2"&gt;+
                        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"password retrieval, important notifications, etc."
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Email { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Required&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"You must specify a password." &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringLength&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;64 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"You must specify a password of {2} or more characters." &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        MinimumLength &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;7 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DataType&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DataType&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password )]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Display&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Password" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Description &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Passwords must be at least 7 characters long." &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DataType&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DataType&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password )]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Display&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(
        Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Confirm password" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        Description &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"Please reenter your password and ensure that it matches the one above."
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Compare&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Password" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"The Password and Confirmation Password must match" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ConfirmPassword { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;; }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This is a standard RegisterModel that gets created with the MVC3 Internet Application project template. There is a little addition to the model in the form of the DisplayAttribute’s Description property.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;In order to show the additional information we will use a jQuery ToolTip plugin from jQuery Tools (see the references section). The plugin requires that each field to have a title attribute so the first task will be to write the value of the Description property into the title attribute.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We will use an Editor Template for the RegisterModel class and we do this by adding a folder called EditorTemplates in the Views\SharedFolder. In order to be picked up automatically by the EditorFor helpers the template needs to have the same name as the class (RegisterModel.cshtml in our case):&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;RegisterModel.cshtml:&lt;/strong&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Various&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RegisterModel
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;UserName , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor( 
        model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;UserName , 
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ModelMetadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FromLambdaExpression&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RegisterModel &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(
            model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;UserName , ViewData )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Description } )  
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;UserName )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Email , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor( 
        model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Email , 
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ModelMetadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FromLambdaExpression&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RegisterModel &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( 
            model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Email , ViewData )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Description } )  
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Email )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor( 
        model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password , 
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ModelMetadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FromLambdaExpression&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RegisterModel &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( 
            model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password , ViewData )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Description } )  
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Password )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ConfirmPassword , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor( 
        model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ConfirmPassword , 
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ModelMetadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FromLambdaExpression&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RegisterModel &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( 
            model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ConfirmPassword , ViewData )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Description } )  
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ConfirmPassword )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Two things are to be noted here:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The Label helper is the one from this post: &lt;/font&gt;&lt;a title="http://weblogs.asp.net/raduenuca/archive/2011/02/17/asp-net-mvc-display-visual-hints-for-the-required-fields-in-your-model.aspx" href="http://weblogs.asp.net/raduenuca/archive/2011/02/17/asp-net-mvc-display-visual-hints-for-the-required-fields-in-your-model.aspx" target="_blank"&gt;&lt;font size="2"&gt;ASP.NET MVC – Display visual hints for the required fields in your model&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The value of title attribute is set by calling the static generic method FromLambdaExpression from the ModelMetadata class. The type parameters are the model type from which we want to extract metadata and the type of the property. For parameters we have an expression that identifies the model and the view data dictionary. The function returns a ModelMetadata object and we read the value of the Description property.&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We call the template from the Register.cshtml view:&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;Register.cshtml:&lt;/strong&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( ) )
{ 
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Register&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorForModel()
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Register" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;/&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Everything is set except for the tooltip.&lt;/p&gt;

&lt;h2 align="justify"&gt;Adding a jQuery Tools Tooltip plugin&lt;/h2&gt;

&lt;p align="justify"&gt;We need to add a reference to the jQuery Tools script file and the ToolTip css file (I’ve used the jQuery Tools CDN but the files can be downloaded and added to the project):&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&amp;lt;!-- include the Tools --&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/javascript" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;src=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"http://cdn.jquerytools.org/1.2.5/tiny/jquery.tools.min.js"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&amp;lt;!-- tooltip styling --&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;link &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;rel=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"stylesheet" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/css" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;href=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"http://static.flowplayer.org/tools/css/tooltip-generic.css"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;/&amp;gt; 
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&amp;lt;!-- javascript coding --&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/javascript"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// execute your scripts when the DOM is ready. this is a good habit
    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// select all desired input fields and attach tooltips to them
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form :input"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;).tooltip({
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// place tooltip on the right edge
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;position: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"center right"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,

            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// a little tweaking of the position
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;offset: [-&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;10&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;],

            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// use the built-in fadeIn/fadeOut effect
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;effect: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"fade"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;,

            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// custom opacity setting
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;opacity: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;&lt;font size="2"&gt;0.7
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;});
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="3"&gt;now when the focus enters a field a tool tip will appear on the right with the description set in the Display attribute.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/Various/ToolTips/Register" target="_blank"&gt;ASP.NET MVC 3 - ToolTip&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;a href="http://flowplayer.org/tools/index.html" target="_blank"&gt;jQuery Tools&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.modelmetadata(v=VS.98).aspx" target="_blank"&gt;ModelMetadata class&lt;/a&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;Download&lt;/font&gt;&lt;/h2&gt;
&lt;font size="2"&gt;&lt;/font&gt;

&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div&gt;&amp;nbsp;&lt;/div&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;

  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 01 May 2011 06:54:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-display-visual-hints-for-the-fields-in-your-form</guid><category>ASP.NET MVC</category><category>jQuery</category></item><item><title>ASP.NET MVC–Displaying a tree view using a recursive declarative helper and jQuery</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-displaying-a-tree-view-using-a-recursive-declarative-helper-and-jquery</link><description>&lt;div&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt;  &lt;div&gt;&lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;h2&gt;Problem&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;font size="2"&gt;You want to display your model using a a nested &amp;lt;ul&amp;gt;, &amp;lt;li&amp;gt; structure&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;font size="2"&gt;You want to be able to click on a leaf and perform an action&lt;/font&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Context&lt;/h2&gt;  &lt;p&gt;We will use the model defined &lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;here&lt;/a&gt; and in order to hold our nested structure we will define a class named Folder:&lt;/p&gt;  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Folder( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Subfolders &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;List&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( );
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public int &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Type { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IList&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Subfolders { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public bool &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsLeaf
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Subfolders&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Count &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        }
    }
}
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;There is nothing complicated about this class. It has some properties and a list of subfolders.&lt;/p&gt;

&lt;p&gt;Let’s create a controller called TreeViewController:&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TreeViewController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Controller
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;ICityRepository &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_cityRepository;

    &lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// If you are using Dependency Injection, you can delete the following constructor
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TreeViewController( ) : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ContinentRepository&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;CityRepository&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) ) { }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TreeViewController( &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository , &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;ICityRepository &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityRepository )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_cityRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityRepository;
    }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpGet&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Atlas( ) );
    }

    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpGet&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCity( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityId )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;city &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_cityRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( cityId );

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Json(
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;city&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name , Population &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;city&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Population } ,
            &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;JsonRequestBehavior&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AllowGet );
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IList&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Atlas( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IList&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;List&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( );

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;foreach &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continent &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;in this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All )
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentFolder &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id ,
                Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name ,
                Type &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"continent"
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;foreach &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;country &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;in &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries )
            {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countryFolder &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;country&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id ,
                    Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;country&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name ,
                    Type &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"country"
                &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};

                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;foreach &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;city &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;in &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;country&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities )
                {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityFolder &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder
                    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                        Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;city&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id ,
                        Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;city&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name ,
                        Type &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"city"
                    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};

                    countryFolder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Subfolders&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( cityFolder );
                }

                continentFolder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Subfolders&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( countryFolder );
            }

            continents&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( continentFolder );
        }

        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continents;
    }
}
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;We have a Index action that will return our view. The Index view receives a list of continents, countries and cities wrapped in a nested Folder structure (the Atlas function is just a quick and dirty way of creating the nested Folder structure). There is also a GetCity action that will return the city information when we will click it in the tree view.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;Index.cshtml:&lt;/strong&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@helper &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TreeView( &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;folders )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;foreach &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;folder &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;in &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;folders )
    {
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;li&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsLeaf )
            {
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"leaf &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Type" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Id"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt; 
            }
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"folder"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;ul&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TreeView( folder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Subfolders )
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;ul&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            }
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;li&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    }
}
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;ul &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"continentFolders"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TreeView( Model )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;ul&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The @helper keyword&amp;nbsp; is a new feature introduced by the Razor view engine, called a declarative helper (for a comparison of MVC 3 Helpers see Jon Galloway’s article in the &lt;em&gt;References&lt;/em&gt; section). The FolderTree helper is nothing more than a recursive function that will output &amp;lt;ul&amp;gt; and &amp;lt;li&amp;gt; tags based on the folders parameter.&lt;/p&gt;

&lt;p align="justify"&gt;If we run this now it will look like this:&lt;/p&gt;

&lt;p align="justify"&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/Projects/TreeView.png"&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/h2&gt;

&lt;h2 align="justify"&gt;Adding a jQuery Tree view plugin&lt;/h2&gt;

&lt;p align="justify"&gt;We can make our tree view more functional by using a jQuery tree plugin (see the &lt;em&gt;References&lt;/em&gt; section):&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  &lt;pre class="code"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/javascript"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continentFolders'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).treeview({ collapsed: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;});

        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;".leaf.city"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).click(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            $.ajax({
                url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Various&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TreeView&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCity( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                data: { cityId: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"id"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) },
                type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                    alert(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Selected city: " &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ data.Name + &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;", population: " &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;+ data.Population.toString());
                }
            });
        });
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="3"&gt;when a city is clicked we make an ajax request to the GetCity action and show some city details.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/Various/TreeView" target="_blank"&gt;ASP.NET MVC 3 - TreeView&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;a href="http://weblogs.asp.net/jgalloway/archive/2011/03/23/comparing-mvc-3-helpers-using-extension-methods-and-declarative-razor-helper.aspx" target="_blank"&gt;Comparing MVC 3 Helpers, by Jon Galloway&lt;/a&gt; | &lt;a href="http://bassistance.de/jquery-plugins/jquery-plugin-treeview/" target="_blank"&gt;jQuery plugin: Treeview&lt;/a&gt; | &lt;a href="http://blog.overridethis.com/blog/post/2010/11/10/Learning-Razore28093Writing-an-Inline-Recursive-HTML-Helper.aspx" target="_blank"&gt;Another implementation I have found, by Roberto Hernández&lt;/a&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;Download&lt;/font&gt;&lt;/h2&gt;
&lt;font size="2"&gt;&lt;/font&gt;

&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div&gt;&amp;nbsp;&lt;/div&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;

  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 24 Apr 2011 17:47:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-displaying-a-tree-view-using-a-recursive-declarative-helper-and-jquery</guid><category>ASP.NET MVC</category><category>Declarative Helper</category><category>jQuery</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 5.3: Cascading using jQuery.ajax() ($.ajax() and Knockout.js)</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part&lt;/a&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt; &lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         
&lt;ul&gt;         
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;strong&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/strong&gt;&lt;/font&gt; &lt;/font&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;  &lt;h1&gt;Part 5.3: Cascading using jQuery.ajax() ($.ajax() and Knockout.js)&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;For this part we will use Knockout.ks:&lt;/font&gt;&lt;/p&gt;
  
&lt;blockquote&gt;   
&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;em&gt;Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably.&lt;/em&gt; (see the References section). &lt;/font&gt;&lt;/p&gt;
    
&lt;p align="justify"&gt;&lt;font size="2"&gt;Before reading further it is better to read the Knockout.js documentation + demos (2-3 hours read) as the things can get really confusing.&lt;/font&gt;&lt;/p&gt;
 &lt;/blockquote&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;We will reuse the controller from Part 5.1 and add a new action called KnockOutJs:&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ViewResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;KnockOutJs( )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;KnockoutJs );
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;And of course the KnockoutJs.cshtml:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"continents" 
            &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;data-bind=&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'
                options: continents, 
                optionsValue : "Id", 
                optionsText: "Name", 
                optionsCaption: "[Please select a continent]", 
                value: selectedContinent'&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countries" 
                &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;data-bind=&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'
                    options: selectedContinent() ? countries : null, 
                    optionsValue : "Id", 
                    optionsText: "Name", 
                    optionsCaption: "[Please select a country]", 
                    value: selectedCountry,
                    visible: (countries() &amp;amp;&amp;amp; countries().length &amp;gt; 0)'&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;data-bind=&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'
            template: {name: "noInfoTemplate"},
            visible: !(countries() &amp;amp;&amp;amp; countries().length &amp;gt; 0)'&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Cities&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;data-bind=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'visible: (cities() &amp;amp;&amp;amp; cities().length &amp;gt; 0 )'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;thead&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                        Name
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                        Population
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;thead&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tbody &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;data-bind=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'template: {name: "citiesTemplate", foreach: cities}'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tbody&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;data-bind=&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;'
            template: {name: "noInfoTemplate"},
            visible: !(cities() &amp;amp;&amp;amp; cities().length &amp;gt; 0 )'&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DateTime&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Now&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"dd/MM/yyyy HH:mm:ss:fff" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/html" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"citiesTemplate"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;tr&amp;gt;
        &amp;lt;td&amp;gt;${Name}&amp;lt;/td&amp;gt;
        &amp;lt;td align='right'&amp;gt;${Population}&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/html" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"noInfoTemplate"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    No Information Available
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Compared to Part 5.1 and 5.2 there is a lot of code but the real power of Knockout.js is when we have a very complex view. Knockout.js introduces an attribute called “data-bind” that binds the html tag to a JavaScript view model, for short.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;For the continents dropdown list we have the following (in exact order of the properties):&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Get the options from the model property called continents&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The option value will be filled from the Id property of each Continent item&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The option text (what we see) will be filled from the Name property of each Continent item&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The first item presented to the use, the option caption, is set to “[Please select a continent]” (the value for this option will be undefined or null)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The value of the selected Continent will go the selectedContinent property from the view model&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;For the countries dropdown list we have the following (in exact order of the properties):&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Get the options from the model property called countries but only if there is a continent selected&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The option value will be filled from the Id property of each Country item&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The option text (what we see) will be filled from the Name property of each Country item&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The first item presented to the use, the option caption, is set to “[Please select a country]” (the value for this option will be undefined or null)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The value of the selected Country will go the selectedCountry property from the view model&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The countries dropdown list will only be visible if the countries property is not null and not empty (visible expects a value that will evaluate to true/false, 1/0, null, undefined)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;For the cities we have the following:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The cities table is only visible if the cities property is not null and not empty&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The cities table body gets its data (the rows) from a template called citiesTemplate which is called for each City in the cities property. We could use the {{each}} template tag directly in the template but in this way if a City is added to the cities array it will be automatically displayed.&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;There are also 2 span tags visible if the countries and cities table are not visible. The span tags get their inner html form the noInfoTemplate.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Now let’s see how the view model looks. Here is the complete script used by this view:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'text/javascript'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.selectedContinent = ko.observable();
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.selectedCountry = ko.observable();
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.continents = ko.observableArray();
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.countries = ko.observableArray();
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;.cities = ko.observableArray();
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// Whenever the continent changes, reset the country selection
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.selectedContinent.subscribe(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(continentId) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.selectedCountry(undefined);
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.countries(undefined);
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(continentId != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    $.ajax({
                        url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCountries( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                        data: { continentId: continentId },
                        type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                        success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                            atlasViewModel.countries(data);
                        }
                    });
                }
            } .bind(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.selectedCountry.subscribe(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(countryId) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;.cities(undefined);
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(countryId != &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    $.ajax({
                        url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCities( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                        data: { countryId: countryId },
                        type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                        success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                            atlasViewModel.cities(data);
                        }
                    });
                }
            } .bind(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;));
        };
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlasViewModel = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;atlas();
        ko.applyBindings(atlasViewModel);
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//Load the continents
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$.ajax({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetContinents( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                atlasViewModel.continents(data);
            }
        });
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Another important piece of the Knockout.js library are the observable properties. When the observable properties change the tags with data-bind attribute will be automatically updated . We can also subscribe to the modification of those properties (as we did for the selectedContinent and selectedCountry properties). Knockout.js is activated by calling the applyBindings method with the view model passed as the argument.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The above code does the following:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;When the document is ready we make an Ajax request for the continents. The continents property of the view model is updated and it triggers the UI update (if there are binding to that property).&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;When we select a continent the selectedContinent property is updated (through the data-bind properties)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Because we have a subscription for the changing of the selectedContinent property our function will be called. &lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;The function will clear the selectedCountry and the cities array (again triggering the UI update)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;If the selected continent is not null (in other words if we haven’t selected the [Please select a continent] option) we make an Ajax request for the countries based on the selected continent id and the countries property is updated with the data received from the server (triggering an UI update).&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The function for the selectedCountry changed event is similar as the selectedContinent one.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownjQueryAjaxPost/KnockOutJs" target="_blank"&gt;Cascading Dropdown Lists - Knockout.js&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The code can be improved by adding 2 dependent observables called countriesVisible and citiesVisible that should be used instead of (countries() &amp;amp;&amp;amp; countries().length &amp;gt; 0) statement. Dependent observables depend on the other properties (they are basically function that return a result based on the other properties). For those reading the documentation should be easy to implement.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;a href="http://knockoutjs.com/documentation/introduction.html" target="_blank"&gt;Knockout.js – Documentation&lt;/a&gt; | &lt;a href="http://knockoutjs.com/examples/" target="_blank"&gt;Knockout.js - Samples&lt;/a&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;Download&lt;/font&gt;&lt;/h2&gt;
&lt;font size="2"&gt;&lt;/font&gt;

&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 17 Apr 2011 17:46:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js</guid><category>ASP.NET MVC</category><category>jQuery</category><category>jQuery Templates</category><category>Knockout.js</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 5.2: Cascading using jQuery.ajax() ($.ajax() and jQuery Templates)</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part 1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         
&lt;ul&gt;         
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;&lt;font size="3"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/font&gt; &lt;/strong&gt;&lt;/font&gt;&lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;    &lt;h1&gt;Part 5.2: Cascading using jQuery.ajax() ($.ajax() and jQuery Templates)&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;We will reuse the controller from Part 5.1 and add a new action called jQueryTemplates:&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ViewResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;jQueryTemplates( )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;jQueryTemplates );
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;And of course the jQueryTemplates.cshtml:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'continentsContainer'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'countriesContainer'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Cities&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"citiesContainer"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Compared to Part 5.1 where we had some empty select tags here we have only empty div tags. We will use jQuery Templates (&lt;em&gt;see the References section for jQuery Templates documentation and samples&lt;/em&gt;) to define templates for the following:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Continents and Countries dropdown lists&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Cities table&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;“No Information available”&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;For the Continents and Countries dropdown lists we will define a template called selectTemplate:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"selectTemplate" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/html"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    {{if options.length}}
        &amp;lt;select id='${id}'&amp;gt;
            &amp;lt;option value=''&amp;gt;${choose}&amp;lt;/option&amp;gt;
            {{each options}}
                &amp;lt;option value='${Id}'&amp;gt;${Name}&amp;lt;/option&amp;gt;
            {{/each}}
        &amp;lt;/select&amp;gt;
    {{else}}
        {{tmpl '#noInfoTemplate'}}
    {{/if}}
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This is how we define a template. It has a name to help identify it and a type. The template receives, as a parameter an object with 3 properties:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;id – becomes the select tag id&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;choose – becomes the first option ([Please select a continent])&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;options – an array of objects that have an Id and Name property&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The ideea si simple. If there are any options then we output a select tag and for each option and option tag. If the options array is empty we call another template called “noInfoTemplate” that will output the text “No Information Available” (or anything we want).&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The citiesTemplate:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"citiesTemplate" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/html"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    {{if cities.length}}
        &amp;lt;table&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Population&amp;lt;/th&amp;gt;
            &amp;lt;/tr&amp;gt;
            {{each cities}}
                &amp;lt;tr&amp;gt;
                    &amp;lt;td&amp;gt;${Name}&amp;lt;/td&amp;gt;
                    &amp;lt;td align='right'&amp;gt;${Population}&amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
            {{/each}}
        &amp;lt;/table&amp;gt;
    {{else}}
        {{tmpl '#noInfoTemplate'}}
    {{/if}}
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We follow the same idea. If the cities array is empty we call the noInfoTemplate, otherwise we output a table by using the {{each}} template tag.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;And finally the very complicated noInfoTemplate:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"noInfoTemplate" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/html"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    No information available
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This is not all. We still need to perform the ajax requests and fill the templates with data. We can copy the functions form Part 5.1 and do some adjustments:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'text/javascript'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//Load the continents
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$.ajax({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetContinents( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#continentsContainer"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#selectTemplate"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).tmpl({
                    id: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'continents'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    choose: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select a continent]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    options: data 
                }));
                $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countriesContainer'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoTemplate'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).tmpl());
                $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#citiesContainer'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoTemplate'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;).tmpl());
            }
        });
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Catch the continents change event
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#citiesContainer'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoTemplate'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).tmpl());
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents option:selected'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                $.ajax({
                    url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCountries( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    data: { continentId: $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents option:selected'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() },
                    type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#countriesContainer"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#selectTemplate"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).tmpl({
                            id: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'countries'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                            choose: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'[Please select a country]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                            options: data 
                        }));
                    }
                });
            }
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countriesContainer'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoTemplate'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;).tmpl());
            }
        });
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Catch the countries change event
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries option:selected'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                $.ajax({
                    url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCities( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    data: { countryId: $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries option:selected'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() },
                    type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                    success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                        $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#citiesContainer"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#citiesTemplate"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).tmpl({ cities: data }));
                    }
                });
            }
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#citiesContainer'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoTemplate'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).tmpl());
            }
        });
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownjQueryAjaxPost/jQueryTemplates" target="_blank"&gt;Cascading Dropdown Lists - jQuery Templates&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;The code is much simple and clean now. We only have 1 line of code to create all 3 tags by calling the tmpl() function with the data returned from the server. But we still have to &lt;/font&gt;&lt;font size="2"&gt;manually call the NoInfoTemplate if no data is returned or if there is nothing selected and there is still a lot of plumbing.&lt;/font&gt;&lt;/p&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;In Part 5.3 we will use Knockout.js to further improve the way we perform the cascading.&lt;/font&gt;&lt;/p&gt;
&lt;strong&gt;
  &lt;h2&gt;&lt;font size="3"&gt;&lt;strong&gt;Download&lt;/strong&gt; &lt;/font&gt;&lt;/h2&gt;
&lt;/strong&gt;
&lt;div id="tabs-6"&gt;
  
&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 10 Apr 2011 19:28:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates</guid><category>ASP.NET MVC</category><category>jQuery</category><category>jQuery Templates</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 5.1: Cascading using jQuery.ajax() ($.ajax() and DOM Objects)</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part 1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         
&lt;ul&gt;         
&lt;li&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;&lt;font size="3"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/font&gt; &lt;/strong&gt;&lt;/font&gt;&lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;  &lt;h1&gt;Part 5.1: Cascading using jQuery.ajax() ($.ajax() and DOM Objects)&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;In this part we will use ASP.NET MVC to create an application that will act more like a JSON service than a Web application. For start let’s create a new controller called DropDownjQueryAjaxPostController:&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropDownjQueryAjaxPostController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;ICountryRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_countryRepository;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;ICityRepository &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_cityRepository;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// If you are using Dependency Injection, you can delete the following constructor
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPostController( ) 
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ContinentRepository&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;CountryRepository&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;CityRepository&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) ) { }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPostController( 
        &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository , 
        &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;ICountryRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countryRepository , 
        &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;ICityRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityRepository )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_countryRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countryRepository;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_cityRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityRepository;
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ViewResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;View( );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Nothing unusual here. We set up repositories and the Index action. The unusual thing is that we return the Index view without any model and that the Index view is the only view we have:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@{
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;}
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'continents'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;option &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;[Please select a continent]&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;option&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countriesContainer"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'countries' &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;style=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;display&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;: none;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;option &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;[Please select a country]&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;option&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;select&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'noInfoCountries'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;No information available &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Cities&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"citiesContainer"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'cities' &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;style=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;display&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;: none;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    Name
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    Population
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'noInfoCities'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;No information available &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;span&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Let’s see what we have:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;An empty continents dropdown list (we could fill the continents from the view but we’ll see another way)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;An empty hidden countries dropdown list&amp;nbsp; and a “No information available” span that will be visible if there is no continent selected&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;An empty hidden cities table and another “No information available” span that will be visible if there is no country selected&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;So the first thing that we have to do is to fill the continents dropdown list when the page loads:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'text/javascript'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//Load the continents
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$.ajax({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetContinents( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;contients = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domContinents = contients.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;); &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// $('#id') != document.getElementById('id')
                //Empty the continents dropdown list
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domContinents.options.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
                    domContinents.remove(i);
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; data.length; i++) {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item = data[i];
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentOption = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Option(item.Name, item.Id);
                    contients.append(continentOption);
                }
            }
        });
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;We use the jQuery.ajax () method (or $.ajax() for short) to perform a Ajax Get request on the GetContinents action. If the call succeds we clear the contents of the dropdownlist and fill it with the data received. Nothing to complicated, just javascript objects and method calls. The only odd thing is the continents and domContinents (see the comment in the code above).&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;Next we need to catch the change event for the continents dropdown list and perform another Ajax Get request to get the countries for the selected continent:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Catch the continents change event
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfo = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoCountries'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domCountries = countries.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domCountries.options.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
        domCountries.remove(i);
    }
    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#cities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).hide();
    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoCities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).show();
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents option:selected'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        $.ajax({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCountries( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            data: { continentId: $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#continents option:selected'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() },
            type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data.length &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; data.length; i++) {
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item = data[i];
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countryOption = &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Option(item.Name, item.Id);
                        countries.append(countryOption);
                    }
                    noInfo.hide();
                    countries.show();
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    countries.hide();
                    noInfo.show();
                }
            }
        });
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;{
        countries.hide();
        noInfo.show();
    }
});&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;When the continents dropdown list selection changes we empty the countries dropdown list. The request is only performed if there is a continent selected, otherwise the “No Information Available” span becomes visible. The span becomes visible also if there are no countries in the continent (for Antarctica).&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Next we catch the countries dropdown list change event:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Catch the countries change event
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#cities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;domCities = cities.get(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = domCities.rows.length - &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i--) {
        domCities.deleteRow(i);
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;noInfo = $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#noInfoCities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;($(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries option:selected'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() != &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;''&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
        $.ajax({
            url: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(236, 118, 0);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Url&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Action( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownjQueryAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCities( ) )&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            data: { countryId: $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries option:selected'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).val() },
            type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'GET'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
            success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data) {
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(data.length &amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) {
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;for &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;i = &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; i &amp;lt; data.length; i++) {
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item = data[i];
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;lastRow = domCities.rows.length;
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityRow = domCities.insertRow(lastRow);
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityName = cityRow.insertCell(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        cityName.innerHTML = item.Name;
                        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cityPopulation = cityRow.insertCell(&lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
                        cityPopulation.innerHTML = item.Population.toString();
                        cityPopulation.align = &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'right'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
                    }
                    noInfo.hide();
                    cities.show();
                }
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                    cities.hide();
                    noInfo.show();
                }
            }
        });
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;{
        countries.hide();
        noInfo.show();
    }
});&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This is it. Not to complicated but there is some code to write.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions//CascadingDropDownLists/DropDownjQueryAjaxPost" target="_blank"&gt;Cascading Dropdown Lists - jQuery.ajax()&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;There are some things that can be improved in this method:&lt;/font&gt;&lt;/p&gt;

&lt;ul&gt;
  
&lt;li&gt;
    &lt;div align="left"&gt;&lt;font size="2"&gt;Using the DOM objects is kind of ugly (adding and removing options and rows)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="left"&gt;&lt;font size="2"&gt;There are a lot of &lt;strong&gt;&lt;em&gt;ifs &lt;/em&gt;&lt;/strong&gt;to hide and show elements depending on selections&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;We will correct them in the next 2 parts&lt;/font&gt;&lt;/p&gt;
&lt;font size="3"&gt;&lt;strong&gt;Download&lt;/strong&gt; &lt;/font&gt;
&lt;div id="tabs-6"&gt;
  
&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 03 Apr 2011 19:24:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects</guid><category>ASP.NET MVC</category><category>jQuery</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 4: Cascading using FORM Hijaxing</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part 1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;&lt;font size="3"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         
&lt;ul&gt;         
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;  &lt;h1&gt;Part 4 – Cascading using FORM Hijaxing&amp;nbsp; &lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h1&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;p align="justify"&gt;&lt;font size="2"&gt;First of all let’s see what we have so far:&lt;/font&gt;&lt;/p&gt;
  
&lt;ul&gt;   
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;In Part 2 we used the Html.BeginForm helper to cascade the dropdown lists. We click a Select button, the page is refreshed entirely and we have the Countries dropdown list filled with data (or the Cities table).&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;In Part 3 we used the Ajax.BeginForm helper to cascade the dropdown lists by updating only a portion of the page. We also have a fallback mechanism in case JavaScript is disabled, in which case the behavior is exactly as in Part 2. We still need to click the Select buttons.&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;
 &lt;/ul&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;In this part we will combine the previous parts (updating only a portion of the page, fallback in case JavaScript is disabled and using Html.BeginForm) and we will remove the need to click a Select button to cascade (this will happen when we select an option from the dropdown list) by&amp;nbsp; using a technique named Hijaxing (see the References section).&lt;/font&gt;&lt;/p&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;We will start by copying the DropDownAjaxPostController and renaming it to DropDownHijaxPostController. Everything stays the same (except for the name of the constructor and the path for the views):&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropDownHijaxPostController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_continentRepository;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// If you are using Dependency Injection, you can delete the following constructor
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPostController( ) : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ContinentRepository&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) ) { }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPostController( &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository;
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( );
        atlas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( atlas );
    }
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
            Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
            Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries
        };
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Request&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsAjaxRequest( ) )
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PartialView( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_Countries , atlas );
        }
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index , atlas );
        }
    }
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue )
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Where( c &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;c&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SingleOrDefault( )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
            SelectedCountryId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId ,
            Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
            Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries ,
            Cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities
        };
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Request&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsAjaxRequest( ) )
        {
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PartialView( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_Cities , atlas );
        }
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Index , atlas );
        }
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Index.cshtml &lt;/strong&gt;is the same as in Ajax.BeginForm method (&lt;em&gt;again the path for the view changes&lt;/em&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/font&gt;&amp;nbsp; 
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@{
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;}
@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Continents )
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countries"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Countries )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"cities"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Cities )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DateTime&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Now&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"dd/MM/yyyy HH:mm:ss:fff"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;)&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;There will be more code in the Index.cshtml view but we’ll get to it later.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;_Continents.cshtml:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent( ) ) )
{ 
     &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        
        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownListFor( 
            m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId , 
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;SelectList&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Id" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Name" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;) , 
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"[Please select a continent]" 
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Select" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;This partial view is identical to the one in Part 2 (Html.BeginForm) except the action and controller where the form will post.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;strong&gt;&lt;font size="2"&gt;_Countries.cshtml:&lt;/font&gt;&lt;/strong&gt; 
&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Count( ) &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( ) ) )
    { 
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HiddenFor( m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId )
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownListFor( 
                    m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedCountryId , 
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;SelectList&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Id" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Name" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;) , 
                    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"[Please select a country]" 
                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Select" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
    }
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        No information available
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;_Cities.cshtml:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The _Cities.cshtml partial view is the same as in Part 2.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;If we run it now it will behave exactly as in Part 2 but this is not what we wanted so let’s start adding some code:&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;First we need to reference the jQuery script and thanks to T4MVC we have intellisense and a cleaner src value:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;    &lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;src=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Links&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;Scripts&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;jquery_1_6_1_min_js" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/javascript"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Next we define a document ready function at the bottom of the Index view:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/javascript"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;&lt;font size="2"&gt;//Code here
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;});
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Because we will post the form when the selected value in the dropdown list changes we don’t need the Select buttons but we cannot remove them either. We need the submit buttons in case JavaScript is disabled so we will hide them using jQuery (if JavaScript is disabled there will be no JavaScript code executed so they will remain visible):&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Hide the submit buttons. If JavaScript is disabled we'll use the normal functionality
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'input[type=submit]'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;).hide();&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Now we need a way to submit Submit the first form to the SelectContinent action. For this we will catch the change event for the Continents dropdown lists, issue a form submit of its parent form, then catch the submit event of the form and perform an $..ajax() call instead:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Continent select
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#SelectedContinentId'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).change(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).parents(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'form'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).submit();
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
});
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Continent form submit
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form[action$='SelectContinent']"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).submit(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    $.ajax({
        url: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'action'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
        type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'post'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        data: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).serialize(),
        success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(result) {
            $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html(result);
            $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'input[type=submit]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).hide();
        }
    });
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
});&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;In case of success we replace the contents of the countries div with the result and hide the select button. We do something similar for the Countries dropdown list:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Country select
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#SelectedCountryId'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).parents(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).submit();
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
});
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Country form submit
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form[action$='SelectCountry']"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'submit'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
    $.ajax({
        url: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'action'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
        type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'post'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        data: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).serialize(),
        success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(result) {
            $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#cities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html(result);
        }
    });
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
});&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Notice that instead of using the change and submit functions directly we used the live function. The jQuery live() function allows us to bind to the events of controls that will be available in the future. At first there is no Countries dropdown list and using the change function will do nothing.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The final Index.cshtml view:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@{
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;}
@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Continents )
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countries"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Countries )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"cities"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownHijaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Cities )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DateTime&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Now&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"dd/MM/yyyy HH:mm:ss:fff"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"text/javascript"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    $(document).ready(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;() {
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Hide the submit buttons. If javascript is disabled we'll use the normal functionality
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'input[type=submit]'&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;).hide();
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Continent select
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#SelectedContinentId'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).change(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).parents(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'form'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).submit();
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;

        });
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Continent form submit
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form[action$='SelectContinent']"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).submit(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            $.ajax({
                url: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'action'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
                type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'post'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                data: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).serialize(),
                success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(result) {
                    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#countries'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html(result);
                    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'input[type=submit]'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).hide();
                }
            });
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
        });
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Country select
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#SelectedCountryId'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'change'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).parents(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).submit();
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
        });
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Country form submit
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;$(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"form[action$='SelectCountry']"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).live(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'submit'&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;() {
            $.ajax({
                url: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).attr(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'action'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;),
                type: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'post'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
                data: $(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).serialize(),
                success: &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;function &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;(result) {
                    $(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'#cities'&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;).html(result);
                }
            });
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return false&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        });
    });
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;script&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownHijaxPost" target="_blank"&gt;Cascading Dropdown Lists - Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;Try it with JavaScript enabled and disabled.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Theoretically speaking we’re done. We perform the dropdown lists cascade using the change event and we also have a fallback mechanism in case JavaScript is disabled. So why go further? Well if you have a requirement that says your web application should be fully functional even if JavaScript is disabled then stop here because in the next part we will trade this functionality for some speed and less code (although you can add some fallback functionality to the next method with some little effort).&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="3"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://domscripting.com/blog/display/41" target="_blank"&gt;&lt;font size="2"&gt;Hijaxing&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; | &lt;/font&gt;&lt;a href="http://api.jquery.com/live/" target="_blank"&gt;&lt;font size="2"&gt;.live() - jQuery API&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; | &lt;/font&gt;&lt;a href="http://api.jquery.com/jQuery.ajax/" target="_blank"&gt;&lt;font size="2"&gt;$.ajax() - jQuery API&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div id="tabs-5"&gt;&lt;/div&gt;
&lt;strong&gt;
  &lt;h2&gt;&lt;font size="3"&gt;&lt;strong&gt;Download&lt;/strong&gt; &lt;/font&gt;&lt;/h2&gt;
&lt;/strong&gt;
&lt;div id="tabs-6"&gt;
  
&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;&lt;font size="2"&gt;Download code&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 27 Mar 2011 19:20:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery</guid><category>ASP.NET MVC</category><category>jQuery</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 3: Cascading using Microsoft AJAX (Ajax.BeginForm helper)</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part 1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         
&lt;ul&gt;         
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;    &lt;h1&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;This method uses the Ajax.BeginForm helper. We will start by copying the DropDownNormalPostController from Part 1 and renaming it to DropDownAjaxPostController. Everything up to and including the Index action is the same as in the DropDownNormalPostController&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropDownAjaxPostController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_continentRepository;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// If you are using Dependency Injection, you can delete the following constructor
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPostController( ) : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ContinentRepository&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) ) { }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPostController( &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository;
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( );
        atlas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;View( atlas );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;


&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;strong&gt;Index.cshtml:&lt;/strong&gt;&lt;/font&gt; 

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@{
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;}
@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Continents )
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countries"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Countries )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"cities"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Cities )
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DateTime&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Now&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"dd/MM/yyyy HH:mm:ss:fff"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;)&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Notice the two div tags called “countries” and “cities”. We will use them to refresh only the Countries and the Cities depending on selection. Below are the partial views:&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;_Continents.cshtml:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Ajax&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent(), &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AjaxOptions &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ UpdateTargetId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"countries" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;} ) )
{ 
     &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        
        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownListFor( 
            m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId , 
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;SelectList&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Id" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Name" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;) , 
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"[Please select a continent]" 
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Select" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Now we are using Ajax.BeginForm instead of Html.BeginForm. The form posts to the same action and it will update the content of the “countries” div with the result (specified in the UpdateTargetId property). &lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The &lt;strong&gt;SelectContinent&lt;/strong&gt; action:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
        Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
        Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries
    };
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Request&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsAjaxRequest( ) )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PartialView( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_Countries , atlas );
    }
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Index , atlas );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The only difference here is the if block. If we have JavaScript enabled there will be an Ajax request and we return the _Countries partial view. When JavaScript is disabled it will behave exactly in Part1 (&lt;em&gt;try this&lt;/em&gt;)&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font size="2"&gt;_Countries.cshtml:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Count( ) &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Ajax&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( ) , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AjaxOptions &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ UpdateTargetId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"cities" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;} ) )
    { 
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HiddenFor( m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownListFor( m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedCountryId , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;SelectList&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Id" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Name" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"[Please select a country]" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Select" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
    }
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        No information available
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;an&lt;font size="2"&gt;d the &lt;strong&gt;SelectCountry&lt;/strong&gt; action:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue )
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Where( c &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;c&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SingleOrDefault( )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
        SelectedCountryId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId ,
        Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
        Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries ,
        Cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities
    };
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Request&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsAjaxRequest( ) )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PartialView( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_Cities , atlas );
    }
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownAjaxPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Index , atlas );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Again, the only difference is the if block.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;_Cities.cshtml:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The _Cities.cshtml partial view is the same as in Part 1.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownAjaxPost" target="_blank"&gt;&lt;font size="2"&gt;Cascading Dropdown Lists - Ajax FORM post&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;Notice that there is no change in the datetime value at the bottom of the Index view, meaning that we do a partial page refresh. The only problem that remains is the need to click the Select buttons. &lt;/font&gt;&lt;/p&gt;

&lt;div id="tabs-5"&gt;&lt;/div&gt;
&lt;strong&gt;
  &lt;h2&gt;&lt;font size="3"&gt;&lt;strong&gt;Download&lt;/strong&gt; &lt;/font&gt;&lt;/h2&gt;
&lt;/strong&gt;
&lt;div id="tabs-6"&gt;
  
&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;Download code&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 20 Mar 2011 19:15:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper</guid><category>Ajax</category><category>ASP.NET MVC</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial–Part 2: Cascading using normal FORM post (Html.BeginForm helper)</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000" size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx" target="_blank"&gt;Part 1 – Defining the problem and the context&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&lt;font size="3"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;font color="#3399ff"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt; &lt;/font&gt;        
&lt;ul&gt;         
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
          
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
          
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;    &lt;h1&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;This method uses the Html.BeginForm helper and no client side scripts. We will start by creating a controller called DropDownNormalPostController:&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropDownNormalPostController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;{
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Because we need to access the database we will need a repository variable (we only need the ContinentRepository because we have the navigation properties defined):&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropDownNormalPostController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_continentRepository;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// If you are using Dependency Injection, you can delete the following constructor
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostController( ) : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ContinentRepository&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) ) { }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostController( &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;continentRepository;
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We will use the default Index action to show the view with the two dropdown lists (Continents and Countries) and a table to show the Cities:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ViewResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( );
    atlas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;View( atlas );
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;Index.cshtml:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@{
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    ViewBag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Title &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Index"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;;
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;}
@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial(&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Continents)
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial(&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Countries)
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Partial(&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_Cities)
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DateTime&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Now&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString(&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"dd/MM/yyyy HH:mm:ss:fff"&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;)&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;As you can see we have a partial view for each of three types. Below are the partial views:&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;_Continents.cshtml:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@*&lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;@using ( Html.BeginForm( "SelectContinent" , "DropDownNormalPost") )&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;*@
@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent( ) ) )
{ 
     &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Continents&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        
        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownListFor( 
            m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId , 
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;SelectList&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Id" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Name" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;) , 
            &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"[Please select a continent]" 
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Select" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;We have a Dropdown list inside a form and when the Select submit button is clicked the form is posted to the SelectContinent action (&lt;em&gt;The commented @using shows how we will normally write a form if we don’t use T4MVC&lt;/em&gt;). &lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The &lt;strong&gt;SelectContinent&lt;/strong&gt; action:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
        Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
        Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries
    };
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Index , atlas );
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The SelectContient action has a nullable int parameter because we don’t have any required constraint on the SelectedContinentId property from the Atlas model. In other words when the user selects the first option ([Please select a continent]) everything will be reset. &lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;Because we need to fill the second dropdown list with countries we will call de Find method from the ContinentRepository and get the Countries property. Next we construct an Atlas object with the data we have so far and pass it to the Index view.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;&lt;font size="2"&gt;_Countries.cshtml:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Count( ) &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( ) , &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;FormMethod&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Post ) )
    { 
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HiddenFor( m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId )
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownListFor( 
                    m &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;m&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedCountryId , 
                    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;SelectList&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Id" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Name" &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;) , 
                    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;&lt;font size="2"&gt;"[Please select a country]" 
                &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Select" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
    }
}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Countries&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        No information available
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;and the &lt;strong&gt;SelectCountry&lt;/strong&gt; action:&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue )
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Where( c &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;c&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SingleOrDefault( )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities
        : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
        SelectedCountryId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId ,
        Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
        Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries ,
        Cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities
    };
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPost&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Index , atlas );
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The only differences here are that we have now two nullable int parameters (selectedContinentId and selectedCountryId) and a little more code (nothing too complicated). &lt;em&gt;We could have only 1 parameter, selectedCountryId and add the CountryRepository besides the ContinentRepository thus simplifying the SelectCountry action a little (Feel free to modify it as an exercise).&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;_Cities.cshtml:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@model &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Mvc3&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Extensions&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Demo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Areas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Models&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Cities&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Count( ) &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
    {
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    Name
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    Population
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;th&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;foreach &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;in &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities )
            {
                &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;td&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Name
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;td&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;td &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;align=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"right"&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;item&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Population&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"0,0" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;td&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;tr&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            }
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;table&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;
    }
    &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;else
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@:&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;text&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;No information available&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;text&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    }
&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;&amp;gt;&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The _Cities.cshtml partial view is a simple table.&lt;/font&gt;&lt;/p&gt;

&lt;h2 align="justify"&gt;&lt;font size="3"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

&lt;p align="justify"&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownNormalPost" target="_blank"&gt;&lt;font size="2"&gt;Cascading Dropdown Lists - Normal FORM post&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;Have you noticed anything ugly about this approach? There are three things:&lt;/font&gt;&lt;/p&gt;

&lt;ol&gt;
  
&lt;li&gt;
    &lt;div align="left"&gt;&lt;font size="2"&gt;We need to click a button in order to apply the selection from the dropdown lists (we will fix this in the following posts)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="left"&gt;&lt;font size="2"&gt;The date and time displayed at the bottom of the Index view changes every time we click a Select button, indicating that we do a full page refresh (we will fix this in the next post)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="left"&gt;&lt;font size="2"&gt;When a Select button is clicked the URL changes from /CascadingDropDownLists/DropDownNormalPost to /CascadingDropDownLists/DropDownNormalPost/SelectContinent or /CascadingDropDownLists/DropDownNormalPost/SelectCountry. Also if we click refresh right after a button click&amp;nbsp; we get a message saying that the form will be submitted again (we fix this below)&lt;/font&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p align="left"&gt;&lt;font size="2"&gt;Here is the modified controller that keeps the same URL and removes the message about form resubmission (using the Post/Redirect/Get method):&lt;/font&gt;&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public partial class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropDownNormalPostPRGController &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Controller
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;private readonly &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;_continentRepository;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;// If you are using Dependency Injection, you can delete the following constructor
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostPRGController( ) : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ContinentRepository&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ) ) { }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostPRGController( &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IContinentRepository &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;continentRepository;
    }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ViewResult &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( )
    {
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TempData[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"atlas" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;as &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        {
            atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( );
            atlas&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All;
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;View( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostPRG&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Views&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index , atlas );
    }
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectContinent( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
            Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
            Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries
        };
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TempData[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"atlas" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;RedirectToAction( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostPRG&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Index( ) );
    }
    [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HttpPost&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;]
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public virtual &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ActionResult &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectCountry( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Find( selectedContinentId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( selectedContinent &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;!= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;HasValue )
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Where( c &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;c&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Id &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Value )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SingleOrDefault( )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities
            : &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Atlas &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
        &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            SelectedContinentId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedContinentId ,
            SelectedCountryId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;selectedCountryId ,
            Continents &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;_continentRepository&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;All ,
            Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;countries ,
            Cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cities
        };
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TempData[ &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"atlas" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;] &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;atlas;
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;RedirectToAction( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MVC&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CascadingDropDownLists&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DropDownNormalPostPRG&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Index( ) );
    }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;The actions are similar, the only difference is that now we use the TempData dictionary to keep the atlas object and redirect to the Index action instead of returning the Index view. In the Index action we look for the atlas object in the TempData dictionary or construct a new one before returning the Index view.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/MVC3Extensions/CascadingDropDownLists/DropDownNormalPostPRG" target="_blank"&gt;Cascading Dropdown Lists - Normal FORM post (PRG)&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="3"&gt;References &lt;/font&gt;&lt;/h2&gt;
&lt;div id="tabs-5"&gt;
  
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Post/Redirect/Get" target="_blank"&gt;Post/Redirect/Get&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id="tabs-6"&gt;
  &lt;h2&gt;&lt;font size="3"&gt;Download&lt;/font&gt;&lt;/h2&gt;
  
&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;Download code&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 13 Mar 2011 19:06:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper</guid><category>ASP.NET MVC</category></item><item><title>ASP.NET MVC–Cascading Dropdown Lists Tutorial</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt;  &lt;div style="margin: 10px; padding: 2px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;   
&lt;ul&gt;     
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;&lt;font size="3"&gt;Part 1 – Defining the problem and the context&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt; &lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/13/asp-net-mvc-cascading-dropdown-lists-tutorial-part-2-cascading-using-normal-form-post-html-beginform-helper.aspx" target="_blank"&gt;Part 2 – Cascading using normal FORM post (Html.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/20/asp-net-mvc-cascading-dropdown-lists-tutorial-part-3-cascading-using-microsoft-ajax-ajax-beginform-helper.aspx" target="_blank"&gt;Part 3 – Cascading using Microsoft AJAX (Ajax.BeginForm helper)&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/03/27/asp-net-mvc-cascading-dropdown-lists-tutorial-part-4-cascading-using-form-hijaxing-using-jquery.aspx" target="_blank"&gt;Part 4 – Cascading using FORM Hijaxing&lt;/a&gt;&lt;/font&gt;&lt;font size="3"&gt; &lt;/font&gt;&lt;/li&gt;
      
&lt;li style="margin-bottom: 5px;"&gt;&lt;font color="#3399ff" size="3"&gt;Part 5 – Cascading using jQuery.ajax():&lt;/font&gt;         
&lt;ul&gt;         
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/03/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-1-cascading-using-jquery-ajax-ajax-and-dom-objects.aspx" target="_blank"&gt;Part 5.1 – $.ajax() and DOM Objects&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/10/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-2-cascading-using-jquery-ajax-ajax-and-jquery-templates.aspx" target="_blank"&gt;Part 5.2 – $.ajax() and jQuery Templates&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
          
&lt;li&gt;&lt;font size="3"&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/04/17/asp-net-mvc-cascading-dropdown-lists-tutorial-part-5-3-cascading-using-jquery-ajax-ajax-and-knockout-js.aspx" target="_blank"&gt;Part 5.3 – $.ajax() and Knockout.js&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
      
&lt;li&gt;&lt;a href="http://weblogs.asp.net/raduenuca/archive/2011/05/08/asp-net-mvc-cascading-dropdown-lists-tutorial-part-6-creating-a-jquery-cascade-plugin.aspx" target="_blank"&gt;&lt;font size="3"&gt;Part 6 – Creating a jQuery Cascade Select Plugin&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
 &lt;/div&gt;  &lt;h1&gt;Part 1 – Defining the problem and the context&lt;/h1&gt;  &lt;h2&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  &lt;h2 align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;ul&gt;   
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to cascade two or more dropdown lists from your view:&lt;/font&gt;&lt;/div&gt;      
&lt;ul&gt;       
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to fill the contents of the next dropdown based on the selection in the current dropdown list. &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to display a list/table filtered based on the selection of the last dropdown list.&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
 &lt;/ul&gt;
  &lt;h2 align="justify"&gt;&lt;font size="2"&gt;Context&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;There are several ways to achieve this, but before drilling into each of them let’s define the context:&lt;/font&gt;&lt;/p&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;Let’s say we want to display a list of continents and when we select a continent another list will be filled with countries from that continent. When we select a country we will show a table with information about cities from that particular country. Something like this:&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/Projects/CascadingDropDownListsSample.png"&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;font size="2"&gt;For this we will use the following model:&lt;/font&gt;&lt;/p&gt;
  
&lt;p&gt;&lt;img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="https://aspblogs.blob.core.windows.net/media/raduenuca/Projects/CascadingDropDownListsModel.png"&gt;&lt;/p&gt;
  &lt;h2 align="justify"&gt;&lt;font size="2"&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;/font&gt;&lt;/h2&gt;  
&lt;p align="justify"&gt;&lt;font size="2"&gt;Before going further let’s prepare the programming environment a little. What we need:&lt;/font&gt;&lt;/p&gt;
  
&lt;ol&gt;   
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Visual Studio 2010 with Service Pack 1 (the edition doesn’t matter):&lt;/font&gt; &lt;/div&gt;      
&lt;ul&gt;       
&lt;li&gt;         &lt;div align="justify"&gt;&lt;em&gt;&lt;font size="2"&gt;You can install it via Web PI (&lt;/font&gt;&lt;/em&gt;&lt;a href="http://www.microsoft.com/web/downloads/platform.aspx" target="_blank"&gt;&lt;em&gt;&lt;font size="2"&gt;Microsoft Web Platform Installer&lt;/font&gt;&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&lt;font size="2"&gt;) or download it from &lt;/font&gt;&lt;/em&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5" target="_blank"&gt;&lt;em&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/em&gt;&lt;/a&gt; &lt;/div&gt;       &lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;ASP.NET MVC 3 Tools Update (and of course ASP.NET MVC 3 RTM):&lt;/font&gt; &lt;/div&gt;      
&lt;ul&gt;       
&lt;li&gt;         &lt;div align="justify"&gt;&lt;em&gt;&lt;font size="2"&gt;You can install it via Web PI or download it from &lt;/font&gt;&lt;/em&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=82cbd599-d29a-43e3-b78b-0f863d22811a&amp;amp;displaylang=en" target="_blank"&gt;&lt;em&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/em&gt;&lt;/a&gt;&lt;font size="2"&gt; . Als&lt;em&gt;o you can read about it &lt;/em&gt;&lt;/font&gt;&lt;a href="http://haacked.com/archive/2011/04/12/introducing-asp-net-mvc-3-tools-update.aspx" target="_blank"&gt;&lt;em&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/em&gt;&lt;/a&gt; &lt;/div&gt;       &lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;NuGet 1.3:&lt;/font&gt; &lt;/div&gt;      
&lt;ul&gt;       
&lt;li&gt;         &lt;div align="justify"&gt;&lt;em&gt;&lt;font size="2"&gt;The 1.2 version will be installed by the MVC 3 Tools Update. You can upgrade it from Visual Studio Extension Manager or from &lt;/font&gt;&lt;/em&gt;&lt;a href="http://nuget.org/" target="_blank"&gt;&lt;em&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/em&gt;&lt;/a&gt; &lt;/div&gt;       &lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;NuGet packages relevant for this tutorial (some of them are installed when you create a new ASP.NET MVC3 project and can be updated):&lt;/font&gt; &lt;/div&gt;      
&lt;ul&gt;       
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;EntityFramework.4.1.10331.0 (pre-installed)&lt;/font&gt; &lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;jQuery.1.6.1 (pre-installed as version 1.5.1 and can be updated from NuGet)&lt;/font&gt; &lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;T4MVC (version at the time of writing 2.6.54)&lt;/font&gt; &lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;SqlServerCompact.(version at the time of writing 4.0.8482.1)&lt;/font&gt; &lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;EntityFramework.SqlServerCompact (version at the time of writing 4.1.8482.2)&lt;/font&gt; &lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;MvcScaffolding.(version at the time of writing 1.0.0) – this must be installed from the NuGet Package Manager Console (Tools\Library Package Manager) by running the command &lt;strong&gt;&lt;em&gt;Install-Package MvcScaffolding&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;/div&gt;       &lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
 &lt;/ol&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;We will use SQL Compact 4.0 to hold the data for this sample and we will access the data using EntityFramework 4.1 and the repository pattern. Lucky for us there is the MvcScaffolding package that will generate pretty much everything. In order to do that we need to run the following commands at the NuGet Package Manager Console (Tools\Library Package Manager) :&lt;/font&gt;&lt;/p&gt;
  
&lt;ol&gt;   
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Scaffold Repository Continent -Area:CascadingDropDownLists &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Scaffold Repository CascadingDropDownLists.Models.Country -Area:CascadingDropDownLists &lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;
    
&lt;li&gt;     &lt;div align="justify"&gt;&lt;font size="2"&gt;Scaffold Repository CascadingDropDownLists.Models.City -Area:CascadingDropDownLists &lt;/font&gt;&lt;/div&gt;      
&lt;p align="justify"&gt;&lt;em&gt;&lt;font size="2"&gt;The –Area parameter is optional. If you don’t have an area you can delete it.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;
      
&lt;p align="justify"&gt;&lt;font size="2"&gt;The result of running the above commands will be 4 files:&lt;/font&gt;&lt;/p&gt;
      
&lt;ol&gt;       
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;ContinentRepository.cs &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;CountryRepository.cs &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;CityRepository.cs &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;
        
&lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;AtlasContext.cs &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;
     &lt;/ol&gt;
   &lt;/li&gt;
 &lt;/ol&gt;
  
&lt;p align="justify"&gt;&lt;font size="2"&gt;Because we will only display data from the database we need to have some seed data. For this we need to create a Database Initializer as follows (&lt;em&gt;&lt;strong&gt;see the whole class in the source code download&lt;/strong&gt;&lt;/em&gt;):&lt;/font&gt;&lt;/p&gt;
  &lt;div style="background-color: rgb(0, 0, 0);"&gt;   
&lt;pre class="code"&gt; &lt;font size="2"&gt;   &lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AtlasContextInitializer &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;DropCreateDatabaseIfModelChanges&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AtlasContext&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&lt;font size="2"&gt;&amp;gt;
    &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;protected override void &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Seed( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;AtlasContext &lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;context )
        {
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Add continents
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;europe &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Continent &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Europe" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;oceania &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Continent &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Oceania" &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};
            &lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Add countries&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;
&lt;font size="2"&gt;            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Europe
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;europe&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Collection&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Country&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&lt;font size="2"&gt;&amp;gt;
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Country&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Russia"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Population &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;142200000&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;}, 
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Country&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Germany"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Population &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;83251851&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;}
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            };
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;var &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;romania &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Country &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{ Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Romania" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Population &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;21698181 &lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;};
            europe&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;Add( romania );
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;
&lt;font size="2"&gt;            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Add cities
            &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;romania&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Collection&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;City&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&lt;font size="2"&gt;&amp;gt;
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
                &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;City &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{Name &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Bucharest"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, Population &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1926334&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;}
&lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;            };
            &lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//Add to context
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            context&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( europe );
            context&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( oceania );
            context&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;SaveChanges( );
        }
    }&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;In order to enable de initializer we need to add the following line in the Application_Start handler in Global.asax.cs:&lt;/font&gt;&lt;/p&gt;

&lt;div align="justify"&gt;
  
&lt;pre&gt;&lt;strong&gt;&lt;font size="2"&gt;System.Data.Entity.Database.SetInitializer( new AtlasContextInitializer( ) );&lt;/font&gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;The database will be created when we first try to read something from it. But this is the job of the next post.&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;em&gt;&lt;font size="2"&gt;I won’t go into further details about EntityFramework 4.1 and the Repository pattern because we will move away from the scope of this post. If you want to learn more please see the links from the References section.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font size="2"&gt;What&amp;nbsp;we have at this moment:&lt;/font&gt;&lt;/p&gt;

&lt;ol&gt;
  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Project setup with NuGet Packages&lt;/font&gt; &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Model to work with&lt;/font&gt; &lt;/div&gt;
  &lt;/li&gt;

  
&lt;li&gt;
    &lt;div align="justify"&gt;&lt;font size="2"&gt;Database with seed data&lt;/font&gt; &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p align="justify"&gt;We will define next a view model called Atlas that will help in the next parts:&lt;/p&gt;

&lt;div style="background-color: rgb(0, 0, 0);"&gt;
  
&lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;&lt;font size="2"&gt;public class &lt;/font&gt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;&lt;font size="2"&gt;Atlas
&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedContinentId { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public int&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SelectedCountryId { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Continent&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Continents { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Country&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Countries { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;City&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Cities { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;/font&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&lt;font size="2"&gt;; }
}&lt;/font&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;In each of the following parts we will create separate controllers, views and partial views even some of the code can be reused. This will help to see the differences from each method used to cascade the dropdown lists.&lt;/font&gt;&lt;/p&gt;

&lt;h2&gt;&lt;font size="2"&gt;References&lt;/font&gt;&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/gg696172(v=VS.103).aspx" target="_blank"&gt;EntityFramework 4.1&lt;/a&gt; | &lt;a href="http://martinfowler.com/eaaCatalog/repository.html" target="_blank"&gt;Repository Pattern&lt;/a&gt; | &lt;a href="http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/" target="_blank"&gt;MvcScaffolding&lt;/a&gt;&lt;/p&gt;

&lt;div id="tabs-6"&gt;
  &lt;h2&gt;&lt;font size="2"&gt;Download&lt;/font&gt;&lt;/h2&gt;
  
&lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;Download code&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;
  &lt;br&gt;&lt;/div&gt;</description><pubDate>Sun, 06 Mar 2011 19:46:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context</guid><category>ASP.NET MVC</category><category>Entity Framework</category><category>MvcScaffolding</category></item><item><title>ASP.NET MVC – Extending the DropDownList to show the items grouped by a category</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-extending-the-dropdownlist-to-show-the-items-grouped-by-a-category</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div id="tabs"&gt;   &lt;ul&gt;     &lt;li&gt;&lt;a href="#tabs-1"&gt;Problem&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="#tabs-2"&gt;Solution&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="#tabs-3"&gt;How it works&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="#tabs-4"&gt;See it in action&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="#tabs-5"&gt;References&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="#tabs-6"&gt;Download&lt;/a&gt; &lt;/li&gt;   &lt;/ul&gt;    &lt;div id="tabs-1"&gt;     &lt;h2&gt;&lt;font size="2"&gt;Problem&lt;/font&gt;&lt;/h2&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to Create/Edit an entity that has a foreign key relationship.&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to be able to select the value for the foreign key from a list.&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want the items that show in the list to be grouped by a category (with the category un-selectable)&lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/div&gt;    &lt;div id="tabs-2"&gt;     &lt;h2&gt;&lt;font size="2"&gt;Solution&lt;/font&gt;&lt;/h2&gt;      &lt;div align="justify"&gt;The first 2 points from the problem statement can be easily accomplished by using a DropDownListFor html helper. For the last thing let’s see how we can solve it in plain html first. There is a html tag called &amp;lt;optgroup&amp;gt; that allows us to group the items:&lt;/div&gt;      &lt;div style="background-color: #000000; overflow: auto"&gt;       &lt;pre class="code"&gt;&lt;span style="color: #f1f2f3"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;select&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;[Please select an option]&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;label=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;Group 1&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 1&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 2&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;label=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;Group 2&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 3&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;4&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 4&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;label=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;Group 3&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 5&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;6&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 6&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;label=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;Group 4&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;7&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 7&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;option &lt;/span&gt;&lt;span style="background: #293134; color: #e0e2e4"&gt;value=&lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;8&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;Option 8&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;option&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;optgroup&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #93c763"&gt;select&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;p align="justify"&gt;As you can see we can mix the the &amp;lt;option&amp;gt; and &amp;lt;optgroup&amp;gt; tags at the same level but the &amp;lt;optgroup&amp;gt; tag cannot contain another &amp;lt;optgroup&amp;gt; tag inside.&lt;/p&gt;

    &lt;p align="justify"&gt;The DropDownList cannot be used to generate the &amp;lt;select&amp;gt; tag as above but we can create our own extension. The DropDownList accepts an IEnumerable&amp;lt;SelectListItem&amp;gt; but we need to pass an IDictionary&amp;lt;string , IEnumerable&amp;lt;SelectListItem&amp;gt;&amp;gt; where the key will represent the category we will use for grouping the items in the DropDownList.&lt;/p&gt;

    &lt;p align="justify"&gt;So it is clear that we need to create a html helper but because this helper will be an extension of the actual DropDownList we will create more overloads for the same helper.&lt;/p&gt;

    &lt;p align="justify"&gt;Luckily for us the source code for ASP.NET MVC is publicly available and we can just grab de DropDownList implementation and bend it to our will. There are 3 things we need to modify:&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;
        &lt;div align="justify"&gt;Replace the IEnumerable&amp;lt;SelectListItem&amp;gt; with IDictionary&amp;lt;string , IEnumerable&amp;lt;SelectListItem&amp;gt;&amp;gt; in all method signatures&lt;/div&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;div align="justify"&gt;Add another overload for the ListItemToOption method that accepts 2 arguments (see below) &lt;/div&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;div align="justify"&gt;Modify the helper method SelectInternal that does all the magic (see below) 
          &lt;br /&gt;&lt;/div&gt;
      &lt;/li&gt;
    &lt;/ol&gt;

    &lt;p align="justify"&gt;This is only relevant code the full source code can be obtained from the Download tab&lt;/p&gt;

    &lt;h3&gt;ListItemToOption (applies to both MVC2 and MVC3):&lt;/h3&gt;

    &lt;div style="background-color: #000000; overflow: auto"&gt;
      &lt;pre class="code"&gt;&lt;span style="color: #93c763"&gt;internal static string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ListItemToOption( &lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;item )
{
    &lt;/span&gt;&lt;span style="color: #678cb1"&gt;TagBuilder &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;builder &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #93c763"&gt;new &lt;/span&gt;&lt;span style="color: #678cb1"&gt;TagBuilder&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( &lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;option&amp;quot; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;)
    {
        InnerHtml &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #678cb1"&gt;HttpUtility&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;HtmlEncode( item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Text )
    };
    &lt;/span&gt;&lt;span style="color: #93c763"&gt;if &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Value &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;!= &lt;/span&gt;&lt;span style="color: #93c763"&gt;null &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;)
    {
        builder&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Attributes[ &lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;value&amp;quot; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;] &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Value;
    }
    &lt;/span&gt;&lt;span style="color: #93c763"&gt;if &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Selected )
    {
        builder&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Attributes[ &lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;selected&amp;quot; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;] &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;selected&amp;quot;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;;
    }
    &lt;/span&gt;&lt;span style="color: #93c763"&gt;return &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;builder&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ToString( &lt;/span&gt;&lt;span style="color: #678cb1"&gt;TagRenderMode&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Normal );
}
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;h3&gt;SelectInternal - relevant code only (applies to both MVC2 and MVC3):&lt;/h3&gt;

    &lt;div style="background-color: #000000; overflow: auto"&gt;
      &lt;pre class="code"&gt;&lt;span style="color: #678cb1"&gt;Dictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;string&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, &lt;/span&gt;&lt;span style="color: #8c8cb4"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;newSelectListDictionary &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= 
    &lt;/span&gt;&lt;span style="color: #93c763"&gt;new &lt;/span&gt;&lt;span style="color: #678cb1"&gt;Dictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;string&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, &lt;/span&gt;&lt;span style="color: #8c8cb4"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( );
&lt;/span&gt;&lt;span style="color: #93c763"&gt;foreach &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( &lt;/span&gt;&lt;span style="color: #93c763"&gt;var &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;category &lt;/span&gt;&lt;span style="color: #93c763"&gt;in &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;selectList&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Keys )
{
    &lt;/span&gt;&lt;span style="color: #678cb1"&gt;List&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;newSelectList &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #93c763"&gt;new &lt;/span&gt;&lt;span style="color: #678cb1"&gt;List&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( );

    &lt;/span&gt;&lt;span style="color: #93c763"&gt;foreach &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( &lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;item &lt;/span&gt;&lt;span style="color: #93c763"&gt;in &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;selectList[ category ] )
    {
        item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Selected &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Value &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;!= &lt;/span&gt;&lt;span style="color: #93c763"&gt;null &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;) &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;? 
            &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;selectedValues&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Contains( item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Value ) : 
            selectedValues&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Contains( item&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Text );
        newSelectList&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Add( item );
    }

    newSelectListDictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Add( category, newSelectList );
}
selectList &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;newSelectListDictionary;
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;div id="tabs-3"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;How it works&lt;/font&gt;&lt;/h2&gt;

    &lt;div&gt;This new extension behaves exactly as a normal DropDownList helper except for the fact that it is accepting an IDictionary&amp;lt;string , IEnumerable&amp;lt;SelectListItem&amp;gt;&amp;gt; instead of an IEnumerable&amp;lt;SelectListItem&amp;gt; and it’s constructing an &amp;lt;optgroup&amp;gt; tag for each key in the dictionary&lt;/div&gt;
  &lt;/div&gt;

  &lt;div id="tabs-4"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

    &lt;div&gt;Let’s consider the following model entities:&lt;/div&gt;

    &lt;div style="background-color: #000000; overflow: auto"&gt;
      &lt;pre class="code"&gt;    &lt;span style="color: #93c763"&gt;public class &lt;/span&gt;&lt;span style="color: #678cb1"&gt;Continent
    &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;{
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public int &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ContinentId { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Name { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
    }

    &lt;/span&gt;&lt;span style="color: #93c763"&gt;public class &lt;/span&gt;&lt;span style="color: #678cb1"&gt;Country
    &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;{
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public int &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountryId { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Name { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public int &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ContinentId { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
    }

    &lt;/span&gt;&lt;span style="color: #93c763"&gt;public class &lt;/span&gt;&lt;span style="color: #678cb1"&gt;City
    &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;{
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public int &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CityId { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Name { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
        &lt;/span&gt;&lt;span style="color: #93c763"&gt;public int &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountryId { &lt;/span&gt;&lt;span style="color: #93c763"&gt;get&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; &lt;/span&gt;&lt;span style="color: #93c763"&gt;set&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;; }
    }
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;div&gt;&amp;#160;&lt;/div&gt;

    &lt;div&gt;In an action method (in CitiesController):&lt;/div&gt;

    &lt;div style="background-color: #000000; overflow: auto"&gt;
      &lt;pre class="code"&gt;    &lt;span style="color: #f1f2f3"&gt;[&lt;/span&gt;&lt;span style="color: #678cb1"&gt;HttpGet&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;]
    &lt;/span&gt;&lt;span style="color: #93c763"&gt;public &lt;/span&gt;&lt;span style="color: #678cb1"&gt;ActionResult &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Create( )
    {
        &lt;/span&gt;&lt;span style="color: #8c8cb4"&gt;IDictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, &lt;/span&gt;&lt;span style="color: #8c8cb4"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;countriesByContinent &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #93c763"&gt;new &lt;/span&gt;&lt;span style="color: #678cb1"&gt;Dictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;string&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, &lt;/span&gt;&lt;span style="color: #8c8cb4"&gt;IEnumerable&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( );

        &lt;/span&gt;&lt;span style="color: #93c763"&gt;foreach &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( &lt;/span&gt;&lt;span style="color: #93c763"&gt;var &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;continent &lt;/span&gt;&lt;span style="color: #93c763"&gt;in this&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;_continents )
        {
            &lt;/span&gt;&lt;span style="color: #93c763"&gt;var &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;countryList &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #93c763"&gt;new &lt;/span&gt;&lt;span style="color: #678cb1"&gt;List&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( );

            &lt;/span&gt;&lt;span style="color: #93c763"&gt;foreach &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;( &lt;/span&gt;&lt;span style="color: #93c763"&gt;var &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;country &lt;/span&gt;&lt;span style="color: #93c763"&gt;in this&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;_countries&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Where( c &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;c&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ContinentId &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;== &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;continent&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ContinentId ) )
            {
                countryList&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Add( &lt;/span&gt;&lt;span style="color: #93c763"&gt;new &lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;{ Value &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;country&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountryId&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;ToString( ), Text &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;country&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Name } );
            }

            countriesByContinent&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Add( continent&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Name, countryList );
        }

        ViewBag&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountriesList &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;= &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;countriesByContinent;

        &lt;/span&gt;&lt;span style="color: #93c763"&gt;return &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;View( );
    }
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;div&gt;&amp;#160;&lt;/div&gt;

    &lt;div&gt;In Create.cshtml: &lt;/div&gt;

    &lt;div style="background-color: #000000; overflow: auto"&gt;
      &lt;pre class="code"&gt;    &lt;span style="background: #22282a; color: #8c8cb4"&gt;@&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;Html&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;DropDownList( c &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;c&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountryId , ViewBag&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountriesList &lt;/span&gt;&lt;span style="color: #93c763"&gt;as &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;IDictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, IEnumerable&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, &lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;[Please select a country]&amp;quot; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;)
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;div&gt;In Create.aspx: &lt;/div&gt;

    &lt;div style="background-color: #000000; overflow: auto"&gt;
      &lt;pre class="code"&gt;    &lt;span style="background: #22282a; color: #8c8cb4"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;: Html&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;DropDownList( c &lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;c&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountryId , ViewBag&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;.&lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;CountriesList &lt;/span&gt;&lt;span style="color: #93c763"&gt;as &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;IDictionary&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #93c763"&gt;string &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, IEnumerable&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #678cb1"&gt;SelectListItem&lt;/span&gt;&lt;span style="color: #e8e2b7"&gt;&amp;gt; &amp;gt; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;, &lt;/span&gt;&lt;span style="color: #ec7600"&gt;&amp;quot;[Please select a country]&amp;quot; &lt;/span&gt;&lt;span style="color: #f1f2f3"&gt;)&lt;/span&gt;&lt;span style="background: #22282a; color: #8c8cb4"&gt;%&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;p&gt;The result:&lt;/p&gt;

    &lt;p&gt;&amp;#160;&lt;a href="http://demos.raduenuca.ro/MVC2Extensions/Select/Cities/Create" target="_blank"&gt;MVC2&lt;/a&gt; | &lt;a href="http://demos.raduenuca.ro/MVC3Extensions/Select/Cities/Create" target="_blank"&gt;MVC3&lt;/a&gt; &lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tabs-5"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;References&lt;/font&gt;&lt;/h2&gt;

    &lt;div&gt;
      &lt;p&gt;&lt;a href="http://www.w3schools.com/tags/tag_optgroup.asp" target="_blank"&gt;HTML &lt;optgroup&gt;Tag&lt;/a&gt; | &lt;a href="http://aspnet.codeplex.com/wikipage?title=MVC&amp;amp;referringTitle=Home" target="_blank"&gt;MVC Source Code&lt;/a&gt; &lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;div id="tabs-6"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;Download&lt;/font&gt;&lt;/h2&gt;

    &lt;div&gt;
      &lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank"&gt;Download code&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;

  &lt;br /&gt;&lt;/div&gt;</description><pubDate>Sat, 26 Feb 2011 17:30:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-extending-the-dropdownlist-to-show-the-items-grouped-by-a-category</guid><category>ASP.NET MVC</category><category>Html Helper</category><category>jQuery</category></item><item><title>ASP.NET MVC – Display visual hints for the required fields in your model</title><link>https://weblogs.asp.net:443/raduenuca/asp-net-mvc-display-visual-hints-for-the-required-fields-in-your-model</link><description>&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;   &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;   &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;    &lt;br&gt;&lt;/div&gt; &lt;!--&lt;h1&gt;&lt;font size="2"&gt;ASP.NET MVC–Display visual hints for the required fields in your model&lt;/font&gt;&lt;/h1&gt;--&gt;  &lt;br&gt;  &lt;div id="tabs"&gt;   &lt;ul&gt;     &lt;li&gt;&lt;a href="http://weblogs.asp.net/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=1215&amp;amp;postid=7707891#tabs-1"&gt;Problem&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="http://weblogs.asp.net/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=1215&amp;amp;postid=7707891#tabs-2"&gt;Solution&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="http://weblogs.asp.net/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=1215&amp;amp;postid=7707891#tabs-3"&gt;How it works&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="http://weblogs.asp.net/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=1215&amp;amp;postid=7707891#tabs-4"&gt;See it in action&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="http://weblogs.asp.net/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=1215&amp;amp;postid=7707891#tabs-5"&gt;References&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="http://weblogs.asp.net/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=1215&amp;amp;postid=7707891#tabs-6"&gt;Download&lt;/a&gt; &lt;/li&gt;   &lt;/ul&gt;    &lt;div id="tabs-1"&gt;     &lt;h2&gt;&lt;font size="2"&gt;Problem&lt;/font&gt;&lt;/h2&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to display visual hints in the view to signal that certain fields are required. &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want the visual hints to be dynamically added when the RequiredAttribute is added to a model property. &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;font size="2"&gt;You want to use a familiar way of displaying the visual hints. &lt;/font&gt;&lt;/div&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/div&gt;    &lt;div id="tabs-2"&gt;     &lt;h2&gt;&lt;font size="2"&gt;Solution&lt;/font&gt;&lt;/h2&gt;      &lt;p&gt;&lt;font size="2"&gt;Let’s analyze each of the requests above:&lt;/font&gt;&lt;/p&gt;      &lt;p&gt;&lt;font size="2"&gt;1. You want to display visual hints in the view to signal that certain fields are required. &lt;/font&gt;&lt;/p&gt;      &lt;blockquote&gt;       &lt;p align="justify"&gt;&lt;font size="2"&gt;The most common way to do this is to add a red star (&lt;font color="#ff0000"&gt;*&lt;/font&gt;) near the field or to color the field label in red.&lt;/font&gt;&lt;/p&gt;     &lt;/blockquote&gt;      &lt;p align="justify"&gt;&lt;font size="2"&gt;2. You want the visual hints to be dynamically added when the RequiredAttribute is added to a model property. &lt;/font&gt;&lt;/p&gt;      &lt;blockquote&gt;       &lt;p align="justify"&gt;&lt;font size="2"&gt;The best way will be to create a html helper, read the IsRequired property from ModelMetadata and output a red star (&amp;lt;span style=”color: red;”&amp;gt;*&amp;lt;span&amp;gt; ). &lt;/font&gt;&lt;/p&gt;        &lt;div style="margin: 10px; padding: 5px; border: 2px solid black; background-color: rgb(255, 255, 102);"&gt;         &lt;p style="font-size: 1.2em;"&gt;Unfortunately for the default ModelMetadataProvider the IsRequired property is always true for all non-nullable properties with or without the RequiredAttribute applied. &lt;/p&gt;       &lt;/div&gt;        &lt;p align="justify"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;        &lt;p align="justify"&gt;&lt;font size="2"&gt;One way to overcome this is to create our own ModelMetadataProvider and set the IsRequired property to true only if the RequiredAttribute is present but there is an alternative solution using reflection. So instead of using the IsRequired property we need to use reflection to see if the RequiredAttribute is present in the custom attributes collection for the current property (see the code bellow).&lt;/font&gt;&lt;/p&gt;        &lt;p align="justify"&gt;&lt;font size="2"&gt;We will end with something like this: &lt;strong&gt;&lt;em&gt;Html.RequiredVisualHintFor( m =&amp;gt; m.FirstName). &lt;/em&gt;&lt;/strong&gt;Now we have the visual hint displayed automatically but we need to add a new html helper besides the LabelFor, TextBoxFor (or OtherInputForhelper) and DisplayMessageFor).&lt;/font&gt;&lt;/p&gt;     &lt;/blockquote&gt;      &lt;p align="justify"&gt;&lt;font size="2"&gt;3. You want to use a familiar way of displaying the visual hints. &lt;/font&gt;&lt;/p&gt;      &lt;ol&gt;       &lt;ol&gt;         &lt;ul&gt;&lt;font size="2"&gt;&lt;!--EndFragment--&gt;&lt;/font&gt;&lt;/ul&gt;       &lt;/ol&gt;     &lt;/ol&gt;      &lt;blockquote&gt;       &lt;p&gt;&lt;font size="2"&gt;The solution at step 2 solves our problem but introduces a new helper and thus adding more code in our view. We already have the Label html control so why not to “extend” it by adding some overloads?&lt;/font&gt;&lt;/p&gt;     &lt;/blockquote&gt;      &lt;h3&gt;MVC2 (relevant code only):&lt;/h3&gt;      &lt;div style="background-color: rgb(0, 0, 0);"&gt;       &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;internal static &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelHelper(
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HtmlHelper &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;html ,
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ModelMetadata &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata ,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;htmlFieldName ,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cssFieldId ,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cssClassName )
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;labelText &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= 
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DisplayName &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PropertyName &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;htmlFieldName&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Split( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'.' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Last( );
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;String&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsNullOrEmpty( labelText ) )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Empty;
    }

    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagBuilder &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;tag &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagBuilder&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"label" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Attributes&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"for" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, 
        html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ViewContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ViewData&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TemplateInfo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetFullHtmlFieldId( htmlFieldName ) );
    tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SetInnerText( labelText );

    &lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//The Required attribute has allow multiple false
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;bool &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;isRequired &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= 
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ContainerType&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetProperty( metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PropertyName )
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCustomAttributes( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;typeof&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RequiredAttribute &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Length &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( isRequired )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( cssFieldId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Equals( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringComparison&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;OrdinalIgnoreCase ) )
        {
            tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AddCssClass( cssClassName );
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( cssFieldId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;StartsWith( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) )
            {
                cssFieldId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cssFieldId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Remove( &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1 &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            }
            &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringBuilder &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;jQueryString &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringBuilder&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( )
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagRenderMode&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Normal ) )
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&amp;lt;script type='text/javascript'&amp;gt;" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"$(document).ready(function () {" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"$('#" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( cssFieldId )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"').addClass('" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( cssClassName )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"\')" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"});" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&amp;lt;/script&amp;gt; " &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Create( jQueryString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( ) );
        }
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Create( tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagRenderMode&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Normal ) );
}
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;h3&gt;MVC3 (relevant code only):&lt;/h3&gt;

    &lt;div style="background-color: rgb(0, 0, 0);"&gt;
      &lt;pre class="code"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;internal static &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelHelper(
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;HtmlHelper &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;html ,
    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;ModelMetadata &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata ,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;htmlFieldName ,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;labelText &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cssFieldId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cssClassName &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"field-required" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
{
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;resolvedLabelText &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= 
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;labelText &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;DisplayName &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? 
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PropertyName &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;?? &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;htmlFieldName&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Split( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;'.' &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Last( );

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;String&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;IsNullOrEmpty( resolvedLabelText ) )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Empty;
    }

    &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagBuilder &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;tag &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagBuilder&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"label" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
    tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Attributes&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Add(
        &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"for" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;,
        &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagBuilder&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CreateSanitizedId(
            html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ViewContext&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ViewData&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TemplateInfo&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetFullHtmlFieldName( htmlFieldName )
        )
    );
    tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;SetInnerText( resolvedLabelText );


    &lt;/span&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;//The Required attribute has allow multiple false
    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;bool &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;isRequired &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= 
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ContainerType&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetProperty( metadata&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PropertyName )
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;GetCustomAttributes( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;typeof&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;RequiredAttribute &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;false &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
            &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Length &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;== &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( isRequired )
    {
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( cssFieldId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Equals( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringComparison&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;OrdinalIgnoreCase ) )
        {
            tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;AddCssClass( cssClassName );
        }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;else
        &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;if &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( cssFieldId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;StartsWith( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) )
            {
                cssFieldId &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;cssFieldId&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Remove( &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;0 &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(255, 205, 34);"&gt;1 &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);
            }
            &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringBuilder &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;jQueryString &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;new &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;StringBuilder&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( )
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagRenderMode&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Normal ) )
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&amp;lt;script type='text/javascript'&amp;gt;" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"$(document).ready(function () {" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"$('#" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( cssFieldId )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"').addClass('" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( cssClassName )&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"\')" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"});" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
                &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Append( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"&amp;lt;/script&amp;gt; " &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;);

            &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Create( jQueryString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( ) );
        }
    }

    &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;return &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;MvcHtmlString&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Create( tag&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ToString( &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;TagRenderMode&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Normal ) );
}
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;div id="tabs-3"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;How it works&lt;/font&gt;&lt;/h2&gt;

    &lt;p&gt;As you can see above the whole magic is in identifying if the RequiredAttribute is present, If it is then we add a class to the tag (if the “self” value is present) or we output a jQuery snippet if we need to add the class to another control. After that is all about adding a CSS style for the respective class.&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tabs-4"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;See it in action&lt;/font&gt;&lt;/h2&gt;

    &lt;p&gt;Let’s consider the following model:&lt;/p&gt;

    &lt;div style="background-color: rgb(0, 0, 0);"&gt;
      &lt;pre class="code"&gt;    &lt;span style="color: rgb(147, 199, 99);"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Person
    &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Required&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"The first name is required" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Required&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"The middle name is required" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        [&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;Required&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( ErrorMessage &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"The last name is required" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)]
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public string &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
        &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;public bool &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex { &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;; }
    }
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;p&gt;And the Edit view for it&lt;/p&gt;

    &lt;h3&gt;MVC2 (Edit.aspx)&lt;/h3&gt;

    &lt;div style="background-color: rgb(0, 0, 0);"&gt;
      &lt;pre class="code"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt; Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EnableClientValidation(); &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt; &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Edit" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Person" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) ) 
{&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationSummary(&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Fields&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"divRequired"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"#divRequired" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"field-required3" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"field-required2"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;TextBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;CheckBoxFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor(model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex) &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;p&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Create" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;p&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt; } &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;%&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;h3&gt;MVC3 (Edit.cshtml)&lt;/h3&gt;

    &lt;div style="background-color: rgb(0, 0, 0);"&gt;
      &lt;pre class="code"&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;using &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;( Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;BeginForm( ) )
{
    &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationSummary( &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;true &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;Person&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;legend&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Prefix )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;FirstName )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;id=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"divRequired"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"divRequired" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"field-required3" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName )
                &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;MiddleName )
            &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName , &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"self" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"field-required2" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LastName )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;PrefferedName )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Suffix )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-label"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;LabelFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex , &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;null &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;)
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;class=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"editor-field"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;EditorFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex )
            &lt;/span&gt;&lt;span style="background: rgb(34, 40, 42); color: rgb(140, 140, 180);"&gt;@&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Html&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;ValidationMessageFor( model &lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;=&amp;gt; &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;model&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;Sex )
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;p&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;input &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;type=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"submit" &lt;/span&gt;&lt;span style="background: rgb(41, 49, 52); color: rgb(224, 226, 228);"&gt;value=&lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"Create" &lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;p&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;fieldset&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;&amp;gt;
}
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;p&gt;The styles:&lt;/p&gt;

    &lt;div style="background-color: rgb(0, 0, 0);"&gt;
      &lt;pre class="code"&gt;&lt;span style="color: rgb(102, 116, 123);"&gt;/* Styles for editor and display hints
----------------------------------------------------------*/

&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;.field-required:before
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;red&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;content&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;"*"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
}
&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;.field-required2:after
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;font-style&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;italic&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;font-weight&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;bold&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;red&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;content&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;" (Required)"&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
}
&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;.field-required3
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;border-color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;#666666&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;border-style&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;dashed&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;220px&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;padding&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;5px&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
}
&lt;/span&gt;&lt;span style="color: rgb(103, 140, 177);"&gt;.field-required3 label
&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;{
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;color&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;red&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;font-style&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;italic&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
    &lt;/span&gt;&lt;span style="color: rgb(140, 140, 180);"&gt;font-weight&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;: &lt;/span&gt;&lt;span style="color: rgb(236, 118, 0);"&gt;bold&lt;/span&gt;&lt;span style="color: rgb(241, 242, 243);"&gt;;
}
&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;

    &lt;p&gt;The result:&lt;/p&gt;

    &lt;p&gt;&amp;nbsp;&lt;a href="http://demos.raduenuca.ro/MVC2Extensions" target="_blank" mce_href="http://demos.raduenuca.ro/MVC2Extensions"&gt;MVC2&lt;/a&gt; | &lt;a href="http://demos.raduenuca.ro/MVC3Extensions" target="_blank" mce_href="http://demos.raduenuca.ro/MVC3Extensions"&gt;MVC3&lt;/a&gt; &lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tabs-5"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;References&lt;/font&gt;&lt;/h2&gt;

    &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.requiredattribute.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.requiredattribute.aspx"&gt;RequiredAttribute&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.modelmetadata.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/system.web.mvc.modelmetadata.aspx"&gt;ModelMetadata&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.modelmetadataprovider(VS.100).aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/system.web.mvc.modelmetadataprovider(VS.100).aspx"&gt;ModelMetadataProvider&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;

  &lt;div id="tabs-6"&gt;
    &lt;h2&gt;&lt;font size="2"&gt;Download&lt;/font&gt;&lt;/h2&gt;

    &lt;p&gt;&lt;a href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip" target="_blank" mce_href="http://demos.raduenuca.ro/Download/MVC.Extensions.Solution.zip"&gt;Download code&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;&amp;nbsp;&lt;/div&gt;

&lt;div&gt;&lt;!-- AddThis Button BEGIN --&gt;
  &lt;div style="float: right;" class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like" fb:like:layout="button_count"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_pill_style"&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b" mce_src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d5e25bd3a24ce3b"&gt;&lt;/script&gt;&lt;!-- AddThis Button END --&gt;

  &lt;br&gt;&lt;/div&gt;</description><pubDate>Thu, 17 Feb 2011 21:27:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/raduenuca/asp-net-mvc-display-visual-hints-for-the-required-fields-in-your-model</guid><category>ASP.NET MVC</category><category>Html Helper</category><category>jQuery</category></item></channel></rss>