<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>Dan Wahlin's WebLog</title><link>http://weblogs.asp.net/dwahlin/default.aspx</link><description>jQuery, HTML5, JavaScript, ASP.NET, and XAML</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dwahlin" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="dwahlin" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Getting Started with CSS Media Queries</title><link>http://weblogs.asp.net/dwahlin/archive/2012/05/22/getting-started-with-css-media-queries.aspx</link><pubDate>Tue, 22 May 2012 19:22:28 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8521430</guid><dc:creator>dwahlin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8521430</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/05/22/getting-started-with-css-media-queries.aspx#comments</comments><description>&lt;p&gt;If you've ever printed a page and noticed that it looks different than the actual page displayed in the browser you've more than likely witnessed a CSS media type in action. By using CSS media types such as &amp;quot;print&amp;quot;, backgrounds, navigation bars, and other items can be hidden as a user prints which makes the printed page look much more readable. An example of changing styles through a CSS media type as a page is printed is shown next. This type of code can be placed directly in a &amp;lt;style&amp;gt; element in a given page or in an external style sheet.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@media &lt;/span&gt;print 
{    
    &lt;span style="color: maroon"&gt;body &lt;/span&gt;{
        &lt;span style="color: red"&gt;background-color&lt;/span&gt;: &lt;span style="color: blue"&gt;white&lt;/span&gt;;    
    }

    &lt;span style="color: maroon"&gt;nav &lt;/span&gt;{
        &lt;span style="color: red"&gt;display&lt;/span&gt;: &lt;span style="color: blue"&gt;none&lt;/span&gt;;
    }    
}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;The &lt;em&gt;&lt;strong&gt;print&lt;/strong&gt;&lt;/em&gt; media type is one of many that can be used. A list of the different media types available to target various scenarios is shown next: 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;&lt;b&gt;Media Type&lt;/b&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;&lt;b&gt;When is it used?&lt;/b&gt;&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;3d-glasses&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;3D scenarios&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;all&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;All media types&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;braille&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Braille tactile devices&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;embossed&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Paged Braille printers&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;handheld&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Handheld devices&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;print&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Printed materials&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;projection&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Projected presentations&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;screen&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Different types of screens &lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;speech&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Speech synthesizers&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;tty&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Teletypes and terminals&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="145"&gt;
          &lt;p&gt;tv&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="298"&gt;
          &lt;p&gt;Television devices&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;
    &lt;br /&gt;&lt;/b&gt;Media types can be defined in a web page using several different techniques. When a media type is identified (such as when a print operation occurs in the browser), the style sheet associated with the media type is applied dynamically by the browser. One of the easiest ways to get started using media types is to add the &lt;i&gt;media&lt;/i&gt; attribute of the &amp;lt;link&amp;gt; element as shown next:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;link &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/css&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;media&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;print&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;href&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Styles/print.css&amp;quot; /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;br /&gt;This code will cause the style sheet to be applied only when the specific media type (&amp;quot;print&amp;quot; in this case) is identified by the browser. You can also combine the &lt;i&gt;media&lt;/i&gt; attribute with @import in an HTML page to cause a style sheet to be applied (note that the @import rule is ignored in older browsers though): 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;style &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/css&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;media&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;print&amp;quot;&amp;gt;
    @import &lt;/span&gt;&amp;quot;Style/print.css&amp;quot;;
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If you'd prefer to load a specific style sheet from within another style sheet, @import can be used along with the media type. For example, if you have a style sheet named styles.css and want print styles to be included in it, the following can be added in the file to define the print style sheet along with the media type that it applies to:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@import &lt;/span&gt;url('print.css') print;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;br /&gt;Finally, @media can be used directly in a style sheet as shown earlier to identify a specific media type section: 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@media &lt;/span&gt;print
{
    &lt;span style="color: #006400"&gt;/* custom print styles go here */
&lt;/span&gt;}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;

  &lt;br /&gt;While media types definitely fill a direct need, they can't be used to perform more involved runtime logic. That's where CSS media queries come into play. 

  &lt;br /&gt;&lt;/p&gt;

&lt;h4&gt;
  &lt;br /&gt;Adding CSS Media Queries into the Mix&lt;/h4&gt;

&lt;p&gt;CSS media types can be combined with CSS media queries to dynamically change styles and provide a responsive layout that adapts to different screens. While media types target a specific type of media such as print, you can add more control into your pages and even adjust the overall layout by adding CSS media query expressions. Expressions provide a way to associate logic with a given media type. It's important to note that although CSS media queries can be used to dynamically change the layout of a page, they don't optimize a page for smaller devices. Page optimization normally involves the server transmitting smaller images, minimizing the HTML payload that is sent, and performing other types of optimization tasks. Although CSS media queries can be used to load different types of images, they don't have any effect on the overall HTML that is loaded.&lt;/p&gt;

&lt;p&gt;You can use CSS media queries to target a variety of properties:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Screen height and width &lt;/li&gt;

  &lt;li&gt;Aspect ratio &lt;/li&gt;

  &lt;li&gt;Color &lt;/li&gt;

  &lt;li&gt;Orientation (portrait versus landscape) &lt;/li&gt;

  &lt;li&gt;Visit &lt;a href="http://www.w3.org/TR/css3-mediaqueries"&gt;http://www.w3.org/TR/css3-mediaqueries&lt;/a&gt; for a complete list &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's take a look at how media types and media expressions can be used together to create a CSS media query. The following shows a simple example of some HTML that will be rendered in different devices:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;body&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;wrapper&amp;quot;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;article &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;clearfix&amp;quot;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;This is section 1&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;This is section 2&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;This is section 3&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;article&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;body&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The following CSS is applied to the HTML for styling purposes:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: maroon"&gt;#wrapper 
&lt;/span&gt;{
&lt;span style="color: red"&gt;    width&lt;/span&gt;: &lt;span style="color: blue"&gt;980px&lt;/span&gt;;
&lt;span style="color: red"&gt;    margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0 auto&lt;/span&gt;;
}

&lt;span style="color: maroon"&gt;section 
&lt;/span&gt;{
    &lt;span style="color: red"&gt;border&lt;/span&gt;: &lt;span style="color: blue"&gt;1px solid black&lt;/span&gt;;
    &lt;span style="color: red"&gt;height&lt;/span&gt;: &lt;span style="color: blue"&gt;50px&lt;/span&gt;;
    &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;31%&lt;/span&gt;;
    &lt;span style="color: red"&gt;margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0px 0px 10px 5px&lt;/span&gt;;
    &lt;span style="color: red"&gt;padding&lt;/span&gt;: &lt;span style="color: blue"&gt;5px&lt;/span&gt;;
    &lt;span style="color: red"&gt;font-weight&lt;/span&gt;: &lt;span style="color: blue"&gt;bold&lt;/span&gt;;
    &lt;span style="color: red"&gt;background-color&lt;/span&gt;: &lt;span style="color: blue"&gt;green&lt;/span&gt;;
    &lt;span style="color: red"&gt;color&lt;/span&gt;: &lt;span style="color: blue"&gt;white&lt;/span&gt;;
    &lt;span style="color: red"&gt;float&lt;/span&gt;: &lt;span style="color: blue"&gt;left&lt;/span&gt;;
}

&lt;span style="color: maroon"&gt;.clearfix:before&lt;/span&gt;, &lt;span style="color: maroon"&gt;.clearfix:after &lt;/span&gt;{ &lt;span style="color: red"&gt;content&lt;/span&gt;: &lt;span style="color: blue"&gt;&amp;quot;&amp;quot;&lt;/span&gt;; &lt;span style="color: red"&gt;display&lt;/span&gt;: &lt;span style="color: blue"&gt;table&lt;/span&gt;; }
&lt;span style="color: maroon"&gt;.clearfix:after &lt;/span&gt;{ &lt;span style="color: red"&gt;clear&lt;/span&gt;: &lt;span style="color: blue"&gt;both&lt;/span&gt;; }
&lt;span style="color: maroon"&gt;.clearfix &lt;/span&gt;{ *&lt;span style="color: red"&gt;zoom&lt;/span&gt;: &lt;span style="color: blue"&gt;1&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;When the HTML and CSS is rendered the following output is displayed in the browser: 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_7C987C4F.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_74A0D9ED.png" width="787" height="279" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;What happens when the page is rendered on a phone with a small screen? Although most modern smart phones will display the page fine, the user will likely have to zoom in to read the content and swipe left or right to view specific areas. The experience can be made much better by using CSS media types combined with CSS media queries.&lt;/p&gt;

&lt;p&gt;Let's look at how to target devices that have a max width of 480 pixels and reformat the green boxes shown earlier so that they display vertically instead of horizontally. By stacking the boxes vertically and adjusting their widths the user won't have to zoom in and swipe from left to right to see all of the content. An example of defining a media type of &amp;quot;screen&amp;quot; along with a max-width media query expression is shown next:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@media &lt;/span&gt;screen and (max-width:480px) {
    &lt;span style="color: #006400"&gt;/* custom styles go here */
&lt;/span&gt;}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;This code targets any screen that has a maximum width of 480 pixels using the (max-width:480px) expression and triggers styles defined in the media query's brackets to be applied. A more complete example of checking for a specific max-width and then applying custom styles to the page when the expression returns true: 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@media &lt;/span&gt;screen and (max-width:480px) 
{
    &lt;span style="color: maroon"&gt;#wrapper
    &lt;/span&gt;{
    &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;98%&lt;/span&gt;;
    &lt;span style="color: red"&gt;margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0 auto&lt;/span&gt;;
    }

    &lt;span style="color: maroon"&gt;section
    &lt;/span&gt;{
    &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;98%&lt;/span&gt;;
    &lt;span style="color: red"&gt;margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0px 0px 10px 0px&lt;/span&gt;;
    &lt;span style="color: red"&gt;background-color&lt;/span&gt;: &lt;span style="color: blue"&gt;red&lt;/span&gt;;
    &lt;span style="color: red"&gt;color&lt;/span&gt;: &lt;span style="color: blue"&gt;white&lt;/span&gt;;
    &lt;span style="color: red"&gt;float&lt;/span&gt;: &lt;span style="color: blue"&gt;none&lt;/span&gt;;
    }
}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;When the expression is true the custom &lt;em&gt;#wrapper&lt;/em&gt; and &lt;em&gt;section&lt;/em&gt; element styles are applied dynamically causing the floats to be removed. The result is shown next:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_1A968A44.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_32B9F49F.png" width="616" height="431" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;To target widths between 481 and 979 the following CSS can be written. Looking through the code you'll see that 2 expressions are used. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@media &lt;/span&gt;screen and (min-width: 481px) and (max-width:979px) {
    &lt;span style="color: maroon"&gt;#wrapper
    &lt;/span&gt;{
        &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;98%&lt;/span&gt;;
        &lt;span style="color: red"&gt;margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0 auto&lt;/span&gt;;
    }

    &lt;span style="color: maroon"&gt;section
    &lt;/span&gt;{
        &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;98%&lt;/span&gt;;
        &lt;span style="color: red"&gt;margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0px 0px 10px 0px&lt;/span&gt;;
        &lt;span style="color: red"&gt;background-color&lt;/span&gt;: &lt;span style="color: blue"&gt;#ccc&lt;/span&gt;;
        &lt;span style="color: red"&gt;color&lt;/span&gt;: &lt;span style="color: blue"&gt;black&lt;/span&gt;;
        &lt;span style="color: red"&gt;float&lt;/span&gt;: &lt;span style="color: blue"&gt;none&lt;/span&gt;;
    }
}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Each expression is wrapped in parenthesis and separated with the &amp;quot;and&amp;quot; keyword. Although the code only changes each section's background and text color, additional modifications to the styles could certainly be made. The following image shows the screen that's rendered in the browser.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_71AB753A.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_22CAAFDB.png" width="626" height="420" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Additional media queries can certainly be added to target smaller devices such as iPhone and Android phones. For example to target a max-width of 320 pixels the CSS shown next can be added.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;@media &lt;/span&gt;screen and (max-width: 320px)
{
    &lt;span style="color: maroon"&gt;#wrapper 
    &lt;/span&gt;{
        &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;98%&lt;/span&gt;;
    }
          
    &lt;span style="color: maroon"&gt;section 
    &lt;/span&gt;{
        &lt;span style="color: red"&gt;width&lt;/span&gt;: &lt;span style="color: blue"&gt;98%&lt;/span&gt;;
        &lt;span style="color: red"&gt;margin&lt;/span&gt;: &lt;span style="color: blue"&gt;0px 0px 10px 0px&lt;/span&gt;;
        &lt;span style="color: red"&gt;background-color&lt;/span&gt;: &lt;span style="color: blue"&gt;#000&lt;/span&gt;;
        &lt;span style="color: red"&gt;color&lt;/span&gt;: &lt;span style="color: blue"&gt;white&lt;/span&gt;;
        &lt;span style="color: red"&gt;float&lt;/span&gt;: &lt;span style="color: blue"&gt;none&lt;/span&gt;;
    }
}&lt;br /&gt;  &lt;/pre&gt;

&lt;h4&gt;
  &lt;br /&gt;CSS Media Query Testing&lt;/h4&gt;

&lt;p&gt;Although CSS media queries are fairly straightforward to add, how do you test that they're actually working? You can certainly resize the browser window yourself to do some basic testing but if you want to know exact sizes it's better to take advantage of tools designed for that task. &lt;/p&gt;

&lt;p&gt;Chrome has an extension called Windows Resizer (http://tinyurl.com/WindowsResizer) that allows specific resolutions to be targeted easily. After installing it, an icon shows in the Chrome browser that you can select to pick a target as shown next. Custom resolutions can be added easily. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/clip_image006_5A9CF3FE.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://weblogs.asp.net/blogs/dwahlin/clip_image006_thumb_158426C8.png" width="518" height="496" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;You can also use device emulators if you have them installed or do testing on real devices which is of course highly recommended if you have them. If you don't want to install an emulator, a nice (and reasonably priced) tool that can be used to test iOS devices on Windows is available at &lt;a href="http://www.electricplum.com"&gt;http://www.electricplum.com&lt;/a&gt;. It provides a way to test what web pages look like on iPhone and iPad devices as shown next: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/clip_image008_3F8424F0.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://weblogs.asp.net/blogs/dwahlin/clip_image008_thumb_25AFEEC1.jpg" width="295" height="567" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;In this post you've seen the role that CSS media types and CSS media queries play in providing more responsive web pages. In a future post I'll walk through how a more robust site can benefit from CSS media queries to render pages that look good on a variety of devices. You can download the sample code from this post as well as a more robust example that I’ll blog about later &lt;a href="http://dl.dropbox.com/u/6037348/HTML5AndJavaScript/CSSMediaQueries.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8521430" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery+Mobile/default.aspx">jQuery Mobile</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Mobile/default.aspx">Mobile</category></item><item><title>jQuery Documentation Resources to Speed Up Your Development</title><link>http://weblogs.asp.net/dwahlin/archive/2012/04/20/jquery-documentation-resources-to-speed-up-your-development.aspx</link><pubDate>Fri, 20 Apr 2012 19:16:06 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8399243</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8399243</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/04/20/jquery-documentation-resources-to-speed-up-your-development.aspx#comments</comments><description>&lt;p&gt;We’ve been seeing a sharp increase in the number of people interested in getting started with &lt;a href="http://jquery.com/" target="_blank"&gt;jQuery&lt;/a&gt; lately in our training and consulting business which is exciting since it’s such a great framework to use for client-side coding. If you’ve been fighting with cross-browser issues and want to make client-side development fun again then jQuery is a great way to go in my opinion.&lt;/p&gt;  &lt;p&gt;One of the challenges with learning any new framework is knowing where to find documentation and good sources of examples. Although I normally rely on the standard documentation on the &lt;a href="http://www.jQuery.com"&gt;http://www.jQuery.com&lt;/a&gt; site, there are several other sources out there that can be helpful. Some of the sources are a bit dated, but they still provide a good way to find out more about core functionality. Here’s a quick list of the sites and extensions I’m aware of. If you know of others please let me know by adding a comment and I’ll update the list.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;api.jquery.com&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://api.jquery.com"&gt;     &lt;br /&gt;http://api.jquery.com&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;This is the main documentation site available for jQuery. It’s a great place to find details, but you’ll have to know where to look which can be frustrating sometimes for new developers.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/api.jquery.com_5080A65D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="api.jquery.com" border="0" alt="api.jquery.com" src="http://weblogs.asp.net/blogs/dwahlin/api.jquery.com_thumb_384D1635.png" width="775" height="410" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;jQuery API Search (Chrome Extension)&lt;/h2&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="https://chrome.google.com/webstore/detail/nodlebcfeeenaomnbjpnaoclehblaaab/related?utm_source=chrome-ntp-icon" target="_blank"&gt;Get the extension here&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;This is a nice Chrome extension that adds jQuery API search support to Chrome’s omnibox (the URL/search textbox at the top of the browser). Simply type jq followed by a tab and then enter the function you’d like to get documentation on in the omnibox. The extension will search the APIs on the jQuery.com site and return matching results. Very handy….get it &lt;a href="https://chrome.google.com/webstore/detail/nodlebcfeeenaomnbjpnaoclehblaaab/related?utm_source=chrome-ntp-icon" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/jqueryOmnibar_0FCE3421.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="jqueryOmnibar" border="0" alt="jqueryOmnibar" src="http://weblogs.asp.net/blogs/dwahlin/jqueryOmnibar_thumb_1F8DC925.png" width="792" height="419" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;jQuery API Browser (Chrome Extension)&lt;/h2&gt;  &lt;p&gt;&lt;a href="https://chrome.google.com/webstore/detail/abefhanahjellfbchdmkjdcchkogijhk?utm_source=chrome-ntp-icon" target="_blank"&gt;     &lt;br /&gt;Get the extension here&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;This Chrome extension provides a quick way to search through jQuery documentation without having to open up a webpage. It’s not completely up-to-date but is quick and efficient for finding information about most functions.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/chromeExtension_7E2E2388.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="chromeExtension" border="0" alt="chromeExtension" src="http://weblogs.asp.net/blogs/dwahlin/chromeExtension_thumb_1C2C317D.png" width="787" height="416" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;jQAPI.com    &lt;br /&gt;    &lt;br /&gt;&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://jqapi.com/"&gt;http://jqapi.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Provides a great way to pull up the official documentation using a simplified navigation mechanism. I like how clean the documentation is and how well the search and navigation scheme works. They also have an offline version available which is handy when you don’t have access to the network.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/jqapi_608C22BC.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="jqapi" border="0" alt="jqapi" src="http://weblogs.asp.net/blogs/dwahlin/jqapi_thumb_435654E5.png" width="796" height="421" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;jQuery Source Viewer   &lt;br /&gt;&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://james.padolsey.com/jquery/#v=git"&gt;http://james.padolsey.com/jquery/#v=git&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This site provides a great way to see what’s happening inside the jQuery source code (a great way to learn various JavaScript tips and tricks). Simply type in the function you’d like to explore and the site will display the source code.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/jQuerySourceViewer_6457A1EF.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="jQuerySourceViewer" border="0" alt="jQuerySourceViewer" src="http://weblogs.asp.net/blogs/dwahlin/jQuerySourceViewer_thumb_636F1638.png" width="801" height="424" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;visualjQuery.net&lt;/h2&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://visualjquery.net/"&gt;http://visualjquery.net/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Another documentation site that provides a nice navigation scheme and clean view of the documentation. It’s a little outdated (covers jQuery 1.6).&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/visualjquery.net_1926A6FD.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="visualjquery.net" border="0" alt="visualjquery.net" src="http://weblogs.asp.net/blogs/dwahlin/visualjquery.net_thumb_7CC93F0F.png" width="797" height="422" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;api.jquery.com/browser&lt;/h2&gt; &lt;a href="http://api.jquery.com/browser"&gt;   &lt;br /&gt;http://api.jquery.com/browser&lt;/a&gt;   &lt;br /&gt;  &lt;p&gt;   &lt;br /&gt;This site provides some nice drill-down functionality to find out details about a particular function quickly and easily. It’s out dated but provides a quick way to find out about the core API functions.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/api.jquery.com-browser_3AE259C1.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="api.jquery.com-browser" border="0" alt="api.jquery.com-browser" src="http://weblogs.asp.net/blogs/dwahlin/api.jquery.com-browser_thumb_5FFFA42D.png" width="782" height="414" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;api.jquery.com/visual&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://api.jquery.com/visual"&gt;     &lt;br /&gt;http://api.jquery.com/visual&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;This site is also a bit outdated, but if you’re looking to quickly find details on core functionality it makes it easy to drill-down into specific topics, see related functions, and then get details and samples about a given function.     &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/visualjquery_495D55E6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="visualjQuery" border="0" alt="visualjQuery" src="http://weblogs.asp.net/blogs/dwahlin/visualjquery_thumb_083EB0B5.png" width="786" height="416" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;If you’re interested in learning more about jQuery check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt; course at Pluralsight.com.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/dwahlin/image_5F8B21BF.png" /&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8399243" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>jQuery Tip #7 - Consolidating jQuery Ajax Calls</title><link>http://weblogs.asp.net/dwahlin/archive/2012/04/19/consolidating-jquery-ajax-calls.aspx</link><pubDate>Thu, 19 Apr 2012 07:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8396425</guid><dc:creator>dwahlin</dc:creator><slash:comments>17</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8396425</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/04/19/consolidating-jquery-ajax-calls.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Previous Tips:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/07/jquery-tip-1-defining-a-context-when-using-selectors.aspx"&gt;jQuery Tip #1 - Defining a Context When Using Selectors&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/08/jquery-tip-2-manipulating-the-dom-in-a-loop.aspx"&gt;jQuery Tip #2 - Manipulating the DOM in a Loop&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/16/jquery-tip-3-using-the-data-function.aspx"&gt;jQuery Tip #3 – Using the data() Function&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/26/jquery-tip-4-use-the-on-function-for-event-handling.aspx"&gt;jQuery Tip #4 – Use the on() Function for Event Handling&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/26/jquery-tip-5-using-jquery-s-end-function-to-work-with-sets.aspx" target="_blank"&gt;jQuery Tip #5 – Using jQuery’s end() Function to Work with Sets&lt;/a&gt; &lt;/li&gt; 
&lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/03/13/jquery-tip-6-creating-a-custom-jquery-selector.aspx" target="_blank"&gt;jQuery Tip #6 – Creating a Custom jQuery Selector&lt;/a&gt; &lt;/li&gt; 

&lt;/ul&gt;  &lt;p&gt;   &lt;br /&gt;

&lt;p&gt;As the use of Ajax continues to grow in popularity it's worth taking the time to think through how Ajax calls are structured and used in an application especially if re-use and maintenance are important. If you analyze a lot of the Ajax code out there you'll likely find that calls to the server are scattered throughout scripts and pages. For example, if an Ajax call is made to get a list of jobs, a call is made directly in the script that needs the data. If another page/script needs the same type of data another Ajax call is made. This results in code duplication and complicates maintenance since Ajax calls aren't consolidated. &lt;/p&gt;  &lt;p&gt;While there's certainly nothing wrong with this approach (it gets the job done after all), you can get better re-use out of your Ajax calls by consolidating them into JavaScript objects. In this post I'll talk about how Ajax calls can be consolidated using JavaScript patterns and describe the benefits this approach provides.    &lt;br /&gt;&lt;/p&gt;  &lt;h4&gt;The Case for Consolidation&lt;/h4&gt;  &lt;p&gt;JavaScript libraries such as jQuery make it so easy to make Ajax calls that we often don't think much about the code being written and where it's being used. For example, consider the following code that's used to retrieve customers from a WCF service and update a page with the retrieved data: &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="code"&gt;$(&lt;span style="color: maroon"&gt;'#GetCustomersButton'&lt;/span&gt;).click(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    $.getJSON(&lt;span style="color: maroon"&gt;'../CustomerService.svc/GetCustomers'&lt;/span&gt;,
        &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
            &lt;span style="color: blue"&gt;var &lt;/span&gt;cust = data.d[0];
            $(&lt;span style="color: maroon"&gt;'#ID'&lt;/span&gt;).text(cust.ID);
            $(&lt;span style="color: maroon"&gt;'#FirstName'&lt;/span&gt;).val(cust.FirstName);
            $(&lt;span style="color: maroon"&gt;'#LastName'&lt;/span&gt;).val(cust.LastName);
        });
});&lt;br /&gt;&lt;/pre&gt;



&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Although this code works fine, it can't be re-used across other pages that may also need customer data. If another page or script needs the same data then the getJSON() call will have to be re-written since the manner in which the returned data is processed will more than likely be different. In addition to this potential problem, the code is added into a script that may have completely different responsibilities that are unrelated to calling a service. &lt;/p&gt;

&lt;p&gt;In the object-oriented world we strive to follow the &lt;a href="http://en.wikipedia.org/wiki/Single_responsibility_principle"&gt;single responsibility principle&lt;/a&gt; when designing classes to avoid duplication and provide better re-use. Following this same principle in JavaScript code makes a lot of sense and can lead to better re-use, simplified maintenance, and better overall organization of code in an application. By placing Ajax calls into a re-useable JavaScript object we can use them throughout an application more easily, minimize duplicate code, and provide a better maintenance story. Before jumping into how Ajax calls can be consolidated, let's review a key pattern called the Revealing Module Pattern that can be used to encapsulate JavaScript code. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Encapsulation with the Revealing Module Pattern&lt;/h4&gt;

&lt;p&gt;There are several different patterns that can be used to structure JavaScript code and provide a way for functions to be encapsulated inside of class-like structures (given that JavaScript doesn't officially support the concept of a class). One pattern that can be used is the &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/02/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-module-pattern.aspx" target="_blank"&gt;Revealing Module Pattern&lt;/a&gt;. By using the pattern you can encapsulate variables and functions into an object, achieve re-use, simplify maintenance, and can also help avoid naming collisions. There are several other patterns such as the Prototype Pattern and Revealing Prototype Pattern that can be used (to name just two) but the Revealing Module Pattern provides a simple way to get started creating JavaScript objects that are similar in purpose to C# or Java classes. &lt;/p&gt;

&lt;p&gt;The following code shows an example of some simple code that has no structure applied to it (I call it &amp;quot;Function Spaghetti Code&amp;quot;). With this approach variables and functions are scattered throughout a file with no rhyme or reason as to how they relate to each other. All of the variables and functions defined this way are automatically placed in the global scope which can lead to naming collisions. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;engine = &lt;span style="color: maroon"&gt;'V8'&lt;/span&gt;;

&lt;span style="color: blue"&gt;function &lt;/span&gt;start() {
    alert(&lt;span style="color: maroon"&gt;'Car started ' &lt;/span&gt;+ engine + &lt;span style="color: maroon"&gt;' engine'&lt;/span&gt;);
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;stop() {
    alert(&lt;span style="color: maroon"&gt;'Car stopped ' &lt;/span&gt;+ engine + &lt;span style="color: maroon"&gt;' engine'&lt;/span&gt;);
}

&lt;span style="color: blue"&gt;function &lt;/span&gt;turn() {
    alert(&lt;span style="color: maroon"&gt;'Car turned'&lt;/span&gt;)
}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Listing 1&lt;/b&gt;. Function-based JavaScript Code with no encapsulation. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Listing 2 shows this same code refactored to follow the Revealing Module Pattern. In this simple example the code is encapsulated in an object named &lt;i&gt;car&lt;/i&gt;. Following this pattern allows the code to be organized, variables and functions to be taken out of the global scope, and a re-useable object to be defined that can be used in one or more pages or applications. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Car = &lt;span style="color: blue"&gt;function &lt;/span&gt;(engine) {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;start = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        alert(&lt;span style="color: maroon"&gt;'Car started ' &lt;/span&gt;+ engine + &lt;span style="color: maroon"&gt;' engine'&lt;/span&gt;);
    },
    stop = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        alert(&lt;span style="color: maroon"&gt;'Car stopped ' &lt;/span&gt;+ engine + &lt;span style="color: maroon"&gt;' engine'&lt;/span&gt;);
    },
    turn = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        alert(&lt;span style="color: maroon"&gt;'Car turned'&lt;/span&gt;);
    };

    &lt;span style="color: blue"&gt;return &lt;/span&gt;{
        start: start,
        stop: stop,
        turn: turn
    };
}(&lt;span style="color: maroon"&gt;'V8'&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;




&lt;p&gt;&lt;b&gt;Listing 2&lt;/b&gt;. Organize functions in an object to provide encapsulation, re-use, easier maintenance, and to help avoid naming collisions. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Looking through the code in Listing 2 you'll see that 3 functions are defined including start(), stop(), and turn(). All three are publicly exposed to consumers using the return object that's defined (an object literal). Any functions not listed in the return object are inaccessible to consumers making them similar to private members in object-oriented languages. Since the car object is self-invoked (note the parenthesis at the end of Listing 2) you can call it directly using code such as the following: &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;car.start();
car.stop();
car.turn();&lt;br /&gt; &lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If you want to create a new instance of &lt;i&gt;car&lt;/i&gt; the code in Listing 3 can be used instead of the code shown in Listing 2. Notice that the Car object starts with an upper-case character so that the consumer knows to create a new instance of the object to use it. This is a common convention being used more and more among JavaScript developers. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;Car = &lt;span style="color: blue"&gt;function &lt;/span&gt;(engine) {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;start = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        alert(&lt;span style="color: maroon"&gt;'Car started ' &lt;/span&gt;+ engine + &lt;span style="color: maroon"&gt;' engine'&lt;/span&gt;);
    },
    stop = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        alert(&lt;span style="color: maroon"&gt;'Car stopped ' &lt;/span&gt;+ engine + &lt;span style="color: maroon"&gt;' engine'&lt;/span&gt;);
    },
    turn = &lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        alert(&lt;span style="color: maroon"&gt;'Car turned'&lt;/span&gt;);
    };

    &lt;span style="color: blue"&gt;return &lt;/span&gt;{
        start: start,
        stop: stop,
        turn: turn
    };
};&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Listing 3&lt;/b&gt;. Using the Revealing Module Pattern to create a Car object that can be created using the &amp;quot;new&amp;quot; keyword. 

  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;To use the Car object the following code can be written: &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;car = &lt;span style="color: blue"&gt;new &lt;/span&gt;Car(&lt;span style="color: maroon"&gt;'V8'&lt;/span&gt;);
car.start();
car.stop();
car.turn(); &lt;br /&gt;&lt;/pre&gt;



&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If you only need one object in memory as an application is running the code shown in Listing 2 works well. If you need multiple instances of an object the self-invoking parenthesis can be removed as shown in Listing 3. &lt;/p&gt;

&lt;p&gt;Now that you've seen how the Revealing Module Pattern can be used to structure JavaScript code, let's see how it can encapsulate Ajax functions into an object. &lt;/p&gt;

&lt;h4&gt;
  &lt;br /&gt;Consolidating Ajax Calls&lt;/h4&gt;

&lt;p&gt;A sample application named Account at a Glance (download it &lt;a href="http://dl.dropbox.com/u/6037348/AccountAtAGlance.zip"&gt;here&lt;/a&gt; – an image from the application is shown below) built to demonstrate several HTML5, jQuery, and general JavaScript concepts relies on the Revealing Module Pattern to consolidate Ajax calls into a single object that can be re-used throughout the application. By following this pattern, an Ajax call used to retrieve market quotes can be defined in one place and then called from other scripts that may need the data. This approach provides several benefits including more modular, re-useable, and maintainable code. If something changes with an Ajax call you can go to one place to make the core modifications rather than searching through multiple scripts and pages to find where changes need to be made. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/clip_image002_1D1AEB8B.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://weblogs.asp.net/blogs/dwahlin/clip_image002_thumb_3465EFFC.png" width="714" height="383" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;To access market quote data in the application the following call could be made as data is needed in a given script: &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;$.getJSON(&lt;span style="color: maroon"&gt;'/DataService/GetQuote'&lt;/span&gt;, { symbol: sym }, &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
    &lt;span style="color: #006400"&gt;//process data here 
&lt;/span&gt;}); &lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Although this code works, it's much better from a re-use and maintenance standpoint to consolidate calls into an object. Listing 4 shows an example of an Ajax-specific object named dataService that the Account at a Glance application uses to retrieve different types of JSON data from the server. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;dataService = &lt;span style="color: blue"&gt;new function &lt;/span&gt;() {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;serviceBase = &lt;span style="color: maroon"&gt;'/DataService/'&lt;/span&gt;,
    getAccount = &lt;span style="color: blue"&gt;function &lt;/span&gt;(acctNumber, callback) {
        $.getJSON(serviceBase + &lt;span style="color: maroon"&gt;'GetAccount'&lt;/span&gt;, { acctNumber: acctNumber },
          &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
              callback(data);
          });
    },

    getMarketIndexes = &lt;span style="color: blue"&gt;function &lt;/span&gt;(callback) {
        $.getJSON(serviceBase + &lt;span style="color: maroon"&gt;'GetMarketIndexes'&lt;/span&gt;, &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
            callback(data);
        });
    },

    getQuote = &lt;span style="color: blue"&gt;function &lt;/span&gt;(sym, callback) {
        $.getJSON(serviceBase + &lt;span style="color: maroon"&gt;'GetQuote'&lt;/span&gt;, { symbol: sym }, &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
            callback(data);
        });
    },

    getTickerQuotes = &lt;span style="color: blue"&gt;function &lt;/span&gt;(callback) {
        $.getJSON(serviceBase + &lt;span style="color: maroon"&gt;'GetTickerQuotes'&lt;/span&gt;, &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
            callback(data);
        });
    };

    &lt;span style="color: blue"&gt;return &lt;/span&gt;{
        getAccount: getAccount,
        getMarketIndexes: getMarketIndexes,
        getQuote: getQuote,
        getTickerQuotes: getTickerQuotes
    };

} ();&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Listing 4&lt;/b&gt;. Consolidating Ajax calls into a dataService object. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;The dataService object follows the Revealing Module Pattern discussed earlier to encapsulate the various functions. A single instance is created initially at runtime (the dataService function is self-invoked as the script initially loads) that exposes four functions responsible for getting account, market, quote, and ticker data from the server. &lt;/p&gt;

&lt;p&gt;Looking through each function in the dataService object you'll notice that they all accept a callback parameter. Because each function is re-useable, it won't know how to handle the data that's retrieved from a given service - processing of data is unique to the caller of the function. As a result, each function in dataService allows the caller to pass a callback function that is invoked once the data returns from the service to the client. An example of calling the dataService object's getAccount() function is shown next: 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;dataService.getAccount(acctNumber, renderAccountTiles);&lt;br /&gt;&lt;/pre&gt;



&lt;p&gt;
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;When the data is returned the getAccount() function will invoke the renderAccountTiles callback function shown in Listing 5. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;renderAccountTiles = &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
    $(&lt;span style="color: maroon"&gt;'div.tile[id^=&amp;quot;Account&amp;quot;]'&lt;/span&gt;).each(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        sceneStateManager.renderTile(data, $(&lt;span style="color: blue"&gt;this&lt;/span&gt;), 500);
    });
}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Listing 5&lt;/b&gt;. The renderAccountTiles() function handles data returned from the call to dataService.getAccount(). 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Note that a nested/inline callback function could be passed to getAccount() as well as shown next: &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;dataService.getAccount(acctNumber, &lt;span style="color: blue"&gt;function &lt;/span&gt;(data) {
    &lt;span style="color: #006400"&gt;//Process data here
&lt;/span&gt;}); &lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Anytime a script in the application needs to retrieve data from the server a call can be made to one of the dataService object's functions and required parameters can be passed along with the callback. This technique provides a flexible way for Ajax functionality to be consolidated into an object while remaining flexible as far as callbacks go. &lt;/p&gt;

&lt;p&gt;This technique can be applied to other parts of an application as well to create additional objects that encapsulate related variables and functions. By focusing on objects rather than functions you can more efficiently organize code in an application and achieve many of the benefits mentioned earlier such as better re-use and simplified maintenance. Eliminating Function Spaghetti Code is definitely a good thing. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;If you'd like additional details about structuring JavaScript code or building an end-to-end application check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;Structuring JavaScript Code&lt;/a&gt; or &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development"&gt;Building an ASP.NET MVC, EF Code First, HTML5, and jQuery&lt;/a&gt; courses from Pluralsight. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8396425" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Ajax/default.aspx">Ajax</category></item><item><title>Pluralsight Meet the Author Podcast on Structuring JavaScript Code</title><link>http://weblogs.asp.net/dwahlin/archive/2012/04/10/pluralsight-meet-the-author-podcast-on-structuring-javascript-code.aspx</link><pubDate>Wed, 11 Apr 2012 06:00:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8384565</guid><dc:creator>dwahlin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8384565</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/04/10/pluralsight-meet-the-author-podcast-on-structuring-javascript-code.aspx#comments</comments><description>&lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/dwahlin/image_4911B43B.png" width="797" height="117" /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;I had the opportunity to talk with &lt;a href="http://www.pluralsight-training.net/microsoft/Authors/Details?handle=fritz-onion" target="_blank"&gt;Fritz Onion&lt;/a&gt; from Pluralsight about one of my recent courses titled &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; for one of their &lt;a href="http://blog.pluralsight.com/2012/04/09/meet-the-author-dan-wahlin-on-structuring-javascript-code/" target="_blank"&gt;Meet the Author&lt;/a&gt; podcasts. We talked about why JavaScript patterns are important for building more re-useable and maintainable apps, pros and cons of different patterns, and how to go about picking a pattern as a project is started. The course provides a solid walk-through of converting what I call “Function Spaghetti Code” into more modular code that’s easier to maintain, more re-useable, and less susceptible to naming conflicts. Patterns covered in the course include the Prototype Pattern, Revealing Module Pattern, and Revealing Prototype Pattern along with several other tips and techniques that can be used.&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;&lt;a href="https://s3.amazonaws.com/pluralsight-free/meet-the-author/dan-wahlin-structuring-js.mp3"&gt;&lt;img style="border-right-width: 0px; margin-top: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; margin-right: 15px" title="Play Button" alt="Play Button" src="http://pluralsight.files.wordpress.com/2012/03/play-button-16.png?w=640" /&gt;&lt;/a&gt;&lt;a href="https://s3.amazonaws.com/pluralsight-free/meet-the-author/dan-wahlin-structuring-js.mp3"&gt;Meet the Author:&amp;#160; Dan Wahlin on Structuring JavaScript Code&lt;/a&gt;&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; The transcript from the podcast is shown below:   &lt;br /&gt;  &lt;blockquote&gt;   &lt;p&gt;[Fritz]&amp;#160; Hello, this is Fritz Onion with another Pluralsight author interview. Today we’re talking with Dan Wahlin about his new course, Structuring JavaScript Code. Hi, Dan, it’s good to have you with us today.     &lt;br /&gt;&lt;span id="more-3061"&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Thanks for having me, Fritz.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; So, Dan, your new course, which came out in December of 2011 called Structuring JavaScript Code, goes into several patterns of usage in JavaScript as well as ways of organizing your code and what struck me about it was all the different techniques you described for encapsulating your code. I was wondering if you could give us just a little insight into what your motivation was for creating this course and sort of why you decided to write it and record it.&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Sure. So, I got started with JavaScript back in the mid 90s. In fact, back in the days when browsers that most people haven’t heard of were out and we had JavaScript but it wasn’t great. I was on a project in the late 90s that was heavy, heavy JavaScript and we pretty much did what I call in the course function spaghetti code where you just have function after function, there’s no rhyme or reason to how those functions are structured, they just kind of flow and it’s a little bit hard to do maintenance on it, you really don’t get a lot of reuse as far as from an object perspective. And so coming from an object-oriented background in JAVA and C#, I wanted to put something together that highlighted kind of the new way if you will of writing JavaScript because most people start out just writing functions and there’s nothing with that, it works, but it’s definitely not a real reusable solution. So the course is really all about how to move from just kind of function after function after function to the world of more encapsulated code and more reusable and hopefully better maintenance in the process.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; So I am sure a lot of people have had similar experiences with their JavaScript code and will be looking forward to seeing what types of patterns you’ve put forth. Now, a couple I noticed in your course one is you start off with the prototype pattern. Do you want to describe sort of what problem that solves and how you go about using it within JavaScript?&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Sure. So, the patterns that are covered such as the prototype pattern and the revealing module pattern just as two examples, you know, show these kind of three things that I harp on throughout the course of encapsulation, better maintenance, reuse, those types of things. The prototype pattern specifically though has a couple kind of pros over some of the other patterns and that is the ability to extend your code without touching source code and what I mean by that is let’s say you’re writing a library that you know either other teammates or other people just out there on the Internet in general are going to be using. With the prototype pattern, you can actually write your code in such a way that we’re leveraging the JavaScript property and by doing that now you can extend my code that I wrote without touching my source code script or you can even override my code and perform some new functionality. Again, without touching my code.&amp;#160; And so you get kind of the benefit of the almost like inheritance or overriding in object oriented languages with this prototype pattern and it makes it kind of attractive that way definitely from a maintenance standpoint because, you know, you don’t want to modify a script I wrote because I might roll out version 2 and now you’d have to track where you change things and it gets a little tricky. So with this you just override those pieces or extend them and get that functionality and that’s kind of some of the benefits that that pattern offers out of the box.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; And then the revealing module pattern, how does that differ from the prototype pattern and what problem does that solve differently?&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Yeah, so the prototype pattern and there’s another one that’s kind of really closely lined with revealing module pattern called the revealing prototype pattern and it also uses the prototype key word but it’s very similar to the one you just asked about the revealing module pattern.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; Okay.&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; This is a really popular one out there. In fact, we did a project for Microsoft that was very, very heavy JavaScript. It was an HMTL5 jQuery type app and we use this pattern for most of the structure if you will for the JavaScript code and what it does in a nutshell is allows you to get that encapsulation so you have really a single function wrapper that wraps all your other child functions but it gives you the ability to do public versus private members and this is kind of a sort of debate out there on the web. Some people feel that all JavaScript code should just be directly accessible and others kind of like to be able to hide their, truly their private stuff and a lot of people do that. You just put an underscore in front of your field or your variable name or your function name and that kind of is the defacto way to say hey, this is private. With the revealing module pattern you can do the equivalent of what objective oriented languages do and actually have private members that you literally can’t get to as an external consumer of the JavaScript code and then you can expose only those members that you want to be public. Now, you don’t get the benefit though of the prototype feature, which is I can’t easily extend the revealing module pattern type code if you don’t like something I’m doing, chances are you’re probably going to have to tweak my code to fix that because we’re not leveraging prototyping but in situations where you’re writing apps that are very specific to a given target app, you know, it’s not a library, it’s not going to be used in other apps all over the place, it’s a pattern I actually like a lot, it’s very simple to get going and then if you do like that public/private feature, it’s available to you.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; Yeah, that’s interesting. So it’s almost, you can either go private by convention just by using a standard naming convention or you can actually enforce it by using the prototype pattern.&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Yeah, that’s exactly right.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; So one of the things that I know I run across in JavaScript and I’m curious to get your take on is we do have all these different techniques of encapsulation and each one is really quite different when you’re using closures versus simply, you know, referencing member variables and adding them to your objects that the syntax changes with each pattern and the usage changes. So what would you recommend for people starting out in a brand new JavaScript project? Should they all sort of decide beforehand on what patterns they’re going to stick to or do you change it based on what part of the library you’re working on? I know that’s one of the points of confusion in this space.&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Yeah, it’s a great question. In fact, I just had a company ask me about that. So which one do I pick and, of course, there’s not one answer fits all.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; Right.&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; So it really depends what you just said is absolutely in my opinion correct, which is I think as a, especially if you’re on a team or even if you’re just an individual a team of one, you should go through and pick out which pattern for this particular project you think is best. Now if it were me, here’s kind of the way I think of it. If I were writing a let’s say base library that several web apps are going to use or even one, but I know that there’s going to be some pieces that I’m not really sure on right now as I’m writing I and I know people might want to hook in that and have some better extension points, then I would look at either the prototype pattern or the revealing prototype. Now, really just a real quick summation between the two the revealing prototype also gives you that public/private stuff like the revealing module pattern does whereas the prototype pattern does not but both of the prototype patterns do give you the benefit of that extension or that hook capability. So, if I were writing a library that I need people to override things or I’m not even sure what I need them to override, I want them to have that option, I’d probably pick a prototype, one of the prototype patterns. If I’m writing some code that is very unique to the app and it’s kind of a one off for this app which is what I think a lot of people are kind of in that mode as writing custom apps for customers, then my personal preference is the revealing module pattern you could always go with the module pattern as well which is very close but I think the revealing module patterns a little bit cleaner and we go through that in the course and explain kind of the syntax there and the differences.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; Great, that makes a lot of sense.&lt;/p&gt;    &lt;p&gt;[Fritz]&amp;#160; I appreciate you taking the time, Dan, and I hope everyone takes a chance to look at your course and sort of make these decisions for themselves in their next JavaScript project. Dan’s course is, Structuring JavaScript Code and it’s available now in the Pluralsight Library. So, thank you very much, Dan.&lt;/p&gt;    &lt;p&gt;[Dan]&amp;#160; Thanks for having me again.&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8384565" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Pluralsight/default.aspx">Pluralsight</category></item><item><title>Testing Mobile Websites with Adobe Shadow</title><link>http://weblogs.asp.net/dwahlin/archive/2012/04/07/testing-mobile-websites-with-adobe-shadow.aspx</link><pubDate>Sun, 08 Apr 2012 03:06:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8380020</guid><dc:creator>dwahlin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8380020</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/04/07/testing-mobile-websites-with-adobe-shadow.aspx#comments</comments><description>&lt;p&gt;&lt;img style="margin: 5px; display: inline; float: left" align="left" src="http://labs.adobe.com/technologies/shadow/images/shadow_128x128.gif" /&gt;&lt;/p&gt;  &lt;p&gt;It’s no surprise that mobile development is all the rage these days. With all of the new mobile devices being released nearly every day the ability for developers to deliver mobile solutions is more important than ever. Nearly every developer or company I’ve talked to recently about mobile development in training classes, at conferences, and on consulting projects says that they need to find a solution to get existing websites into the mobile space. &lt;/p&gt;  &lt;p&gt;Although there are several different frameworks out there that can be used such as &lt;a href="http://www.jquerymobile.com" target="_blank"&gt;jQuery Mobile&lt;/a&gt;, &lt;a href="http://www.sencha.com/products/touch/" target="_blank"&gt;Sencha Touch&lt;/a&gt;, &lt;a href="http://jqtouch.com/" target="_blank"&gt;jQTouch&lt;/a&gt;, and others, how do you test how your site renders on iOS, Android, Blackberry, Windows Phone, and the variety of mobile form factors out there? Although there are different virtual solutions that can be used including &lt;a href="http://electricplum.com/" target="_blank"&gt;Electric Plum&lt;/a&gt; for iOS, emulators, browser plugins for resizing the laptop/desktop browser, and more, at some point you need to test on as many physical devices as possible. This can be extremely challenging and quite time consuming though especially when you consider that you have to manually enter URLs into devices and click links on each one to drill-down into sites.&lt;/p&gt;  &lt;p&gt;Adobe Labs just released a product called Adobe Shadow (thanks to Kurt Sprinzl for letting me know about it) that significantly simplifies testing sites on physical devices, debugging problems you find, and even making live modifications to HTML and CSS content while viewing a site on the device to see how rendering changes. You can view a page in your laptop/desktop browser and have it automatically pushed to all of your devices without actually touching the device (a huge time saver). See a problem with a device? Locate it using the free Chrome extension, pull up inspection tools (based on the Chrome Developer tools) and make live changes through Chrome that appear on the respective device so that it’s easy to identify how problems can be resolved. I’ve been using Adobe Shadow and am very impressed with the amount of time saved and the different features that it offers. In the rest of the post I’ll walk through how to get it installed, get it started, and use it to view and debug pages.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Getting Adobe Shadow Installed&lt;/h2&gt;  &lt;p&gt;The following steps can be used to get Adobe Shadow installed:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;1. Download and install &lt;a href="http://labs.adobe.com/technologies/shadow/" target="_blank"&gt;Adobe Shadow&lt;/a&gt; on your laptop/desktop &lt;/p&gt;  &lt;p&gt;2. Install the &lt;a href="https://chrome.google.com/webstore/detail/ijoeapleklopieoejahbpdnhkjjgddem" target="_blank"&gt;Adobe Shadow extension&lt;/a&gt; for Chrome &lt;/p&gt;  &lt;p&gt;3. Install the &lt;a href="http://itunes.apple.com/us/app/adobe-shadow/id498621426?mt=8" target="_blank"&gt;Adobe Shadow app&lt;/a&gt; on all of your devices (you can find it in various app stores) &lt;/p&gt;  &lt;p&gt;4. Connect your devices to Wifi. Make sure they’re on the same network that your laptop/desktop machine is on&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Getting Adobe Shadow Started&lt;/h2&gt;  &lt;p&gt;Once Adobe Shadow is installed, you’ll need to get it running on your laptop/desktop and on all your mobile devices. The following steps walk through that process:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;1. Start the Adobe Shadow application on your laptop/desktop &lt;/p&gt;  &lt;p&gt;2. Start the Adobe Shadow app on each of your mobile devices &lt;/p&gt;  &lt;p&gt;3. Locate the laptop/desktop name in the list that’s shown on each mobile device:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_1F63341A.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_67149734.png" width="193" height="322" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;4. Select the laptop/desktop name and a passcode will be shown:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_5D988666.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_55543B02.png" width="195" height="325" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;5. Open the Adobe Shadow Chrome extension on the laptop/desktop and enter the passcode for the given device:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_774C70FB.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_168F17CF.png" width="326" height="151" /&gt;&lt;/a&gt;       &lt;br /&gt;      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Using Adobe Shadow to View and Modify Pages&lt;/h2&gt;  &lt;p&gt;Once Adobe Shadow is up and running on your laptop/desktop and on all of your mobile devices you can navigate to a page in Chrome on the laptop/desktop and it will automatically be pushed out to all connected mobile devices. If you have 5 mobile devices setup they’ll all navigate to the page displayed in Chrome (pretty awesome!). This makes it super easy to see how a given page looks on your iPad, Android device, etc. without having to touch the device itself. If you find a problem with a page on a device you can select the device in the Chrome Adobe Shadow extension on your laptop/desktop and select the remote inspector icon (it’s the &amp;lt; &amp;gt; icon):    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/remoteinspection_7CBAE19F.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="remoteinspection" border="0" alt="remoteinspection" src="http://weblogs.asp.net/blogs/dwahlin/remoteinspection_thumb_0DBF0F83.jpg" width="324" height="147" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;This will pull up the Adobe Shadow remote debugging window which contains the standard Chrome Developer tool tabs such as Elements, Resources, Network, etc. Click on the Elements tab to see the HTML rendered for the target device and then drill into the respective HTML content, CSS styles, etc.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/elementinspector_2D01B656.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="elementinspector" border="0" alt="elementinspector" src="http://weblogs.asp.net/blogs/dwahlin/elementinspector_thumb_2093932D.jpg" width="947" height="679" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;As HTML elements are selected in the Adobe Shadow debugging tool they’ll be highlighted on the device itself just like they would if you were debugging a page directly in Chrome with the developer tools. Here’s an example from my Android device that shows how the page looks on the device as I select different HTML elements on the laptop/desktop:    &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_5865D750.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_7DEF54B1.png" width="255" height="424" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;Conclusion&lt;/h2&gt;  &lt;p&gt;I’m really impressed with what I’ve to this point from Adobe Shadow. Controlling pages that display on devices directly from my laptop/desktop is a big time saver and the ability to remotely see changes made through the Chrome Developer Tools (on my laptop/desktop) really pushes the tool over the top. If you’re developing mobile applications it’s definitely something to check out. It’s currently free to download and use. For additional details check out the video below: &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;iframe title="AdobeTV Video Player" height="367" src="http://tv.adobe.com/embed/877/12009/" frameborder="0" width="640" scrolling="no" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8380020" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery+Mobile/default.aspx">jQuery Mobile</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Adobe/default.aspx">Adobe</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Mobile/default.aspx">Mobile</category></item><item><title>jQuery Samples</title><link>http://weblogs.asp.net/dwahlin/archive/2012/04/02/jquery-samples.aspx</link><pubDate>Tue, 03 Apr 2012 04:03:04 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8374050</guid><dc:creator>dwahlin</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8374050</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/04/02/jquery-samples.aspx#comments</comments><description>&lt;p&gt;Here are the jsfiddle samples that &lt;a href="http://johnpapa.net" target="_blank"&gt;John Papa&lt;/a&gt; and I covered in our jQuery Fundamentals workshop at &lt;a href="http://www.devconnections.com"&gt;DevConnections&lt;/a&gt; last week. These were a few of the samples we wrote on the fly (so they’re not “perfect”) using &lt;a href="http://jsfiddle.net"&gt;http://jsfiddle.net&lt;/a&gt; and wanted to share. Additional jQuery samples covering selectors, DOM manipulation, Ajax techniques, as well as sample applications can be &lt;a href="http://dl.dropbox.com/u/6037348/jQuerySamples.zip"&gt;found here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;You can also view the talks John gave at the conference &lt;a href="http://speakerdeck.com/u/johnpapa"&gt;here&lt;/a&gt;.&amp;#160; Code and slides from my talks can be found at the following links:    &lt;br /&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-building-the-account-at-a-glance-asp-net-mvc-ef-code-first-html5-and-jquery-application.aspx" target="_blank"&gt;Building the Account at a Glance ASP.NET MVC, EF Code First, HTML5, and jQuery Application&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-techniques-strategies-and-patterns-for-structuring-javascript-code.aspx" target="_blank"&gt;Techniques, Strategies, and Patterns for Structuring JavaScript Code&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-getting-started-building-windows-8-html-javascript-metro-apps.aspx" target="_blank"&gt;Getting Started Building Windows 8 HTML/JavaScript Metro Apps&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;   &lt;br /&gt;If you’re interested in learning more about jQuery check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals" target="_blank"&gt;jQuery Fundamentals&lt;/a&gt; course at Pluralsight.com.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_5F8B21BF.png" width="791" height="93" /&gt;&lt;/a&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;h4&gt;Using the Data Function&lt;/h4&gt; &lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/dwahlin/pLSvV/1/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Using Object Literals with jQuery&lt;/h4&gt; &lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/dwahlin/DUU9p/2/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Using jQuery each() with string concatenation&lt;/h4&gt; &lt;iframe style="width: 100%; height: 141px" src="http://jsfiddle.net/dwahlin/bbwZr/3/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Using on() to handle child events&lt;/h4&gt; &lt;iframe style="width: 100%; height: 260px" src="http://jsfiddle.net/dwahlin/nCLy6/4/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;jQuery - hover&lt;/h4&gt; &lt;iframe style="width: 100%; height: 180px" src="http://jsfiddle.net/johnpapa/XLWGb/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;jQuery - event handling variations&lt;/h4&gt; &lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/johnpapa/rCXnj/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;jQuery - Twitter (bind, append, appendTo, each, fadeOut, $.getJSON, callback, success, error, complete)r&lt;/h4&gt; &lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/johnpapa/YS3u4/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;jQuery - attr vs prop&lt;/h4&gt; &lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/johnpapa/kPL8w/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;jQuery - Simple selectors&lt;/h4&gt; &lt;iframe style="width: 100%; height: 128px" src="http://jsfiddle.net/johnpapa/Q7kbT/embedded/" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8374050" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Code and Slides: Building the Account at a Glance ASP.NET MVC, EF Code First, HTML5, and jQuery Application</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-building-the-account-at-a-glance-asp-net-mvc-ef-code-first-html5-and-jquery-application.aspx</link><pubDate>Sat, 31 Mar 2012 16:59:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8372034</guid><dc:creator>dwahlin</dc:creator><slash:comments>26</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8372034</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-building-the-account-at-a-glance-asp-net-mvc-ef-code-first-html5-and-jquery-application.aspx#comments</comments><description>&lt;p&gt;This presentation was given at the spring 2012 &lt;a href="http://devconnections.com" target="_blank"&gt;DevConnections&lt;/a&gt; conference in Las Vegas and is based on my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;Pluralsight course&lt;/a&gt;. The presentation shows how several different technologies including ASP.NET MVC, EF Code First, HTML5, jQuery, Canvas, SVG, JavaScript patterns, Ajax, and more can be integrated together to build a robust application. An example of the application in action is shown next:    &lt;br /&gt;    &lt;br /&gt;&lt;img src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_57B0B622.png" width="594" height="317" /&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;br /&gt;  &lt;div style="width: 595px" id="__ss_12234865"&gt;&lt;iframe height="497" marginheight="0" src="http://www.slideshare.net/slideshow/embed_code/12234865" frameborder="0" width="595" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/div&gt;  &lt;div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;View more of my presentations &lt;a href="http://www.slideshare.net/DanWahlin"&gt;here&lt;/a&gt;.&lt;/div&gt;  &lt;p&gt;The complete code (and associated SQL Server database) for the Account at a Glance application can be &lt;a href="http://dl.dropbox.com/u/6037348/AccountAtAGlance.zip"&gt;found here&lt;/a&gt;. Check out the full-length course on the topic at &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;Pluralsight.com&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" border="0" src="http://weblogs.asp.net/blogs/dwahlin/image_29206519.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8372034" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Lambdas/default.aspx">Lambdas</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/IoC/default.aspx">IoC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/DevConnections/default.aspx">DevConnections</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Canvas/default.aspx">Canvas</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/EF+Code+First/default.aspx">EF Code First</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Modernizr/default.aspx">Modernizr</category></item><item><title>Code and Slides: Techniques, Strategies, and Patterns for Structuring JavaScript Code</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-techniques-strategies-and-patterns-for-structuring-javascript-code.aspx</link><pubDate>Sat, 31 Mar 2012 16:42:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8372022</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8372022</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-techniques-strategies-and-patterns-for-structuring-javascript-code.aspx#comments</comments><description>&lt;p&gt;This presentation was given at the spring 2012 &lt;a href="http://devconnections.com" target="_blank"&gt;DevConnections&lt;/a&gt; conference in Las Vegas and is based on my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; course from Pluralsight. The goal of the presentation is to show how closures combined with code patterns can be used to provide structure to JavaScript code and make it more re-useable, maintainable, and less susceptible to naming conflicts.&amp;#160; Topics covered include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Closures&lt;/li&gt;    &lt;li&gt;Using Object literals &lt;/li&gt;    &lt;li&gt;Namespaces &lt;/li&gt;    &lt;li&gt;The Prototype Pattern &lt;/li&gt;    &lt;li&gt;The Revealing Module Pattern &lt;/li&gt;    &lt;li&gt;The Revealing Prototype Pattern &lt;/li&gt; &lt;/ul&gt;  &lt;br /&gt;  &lt;br /&gt;  &lt;div style="width: 595px" id="__ss_12234904"&gt;&lt;iframe height="497" marginheight="0" src="http://www.slideshare.net/slideshow/embed_code/12234904" frameborder="0" width="595" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/div&gt;  &lt;div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;View more of my presentations &lt;a href="http://www.slideshare.net/DanWahlin"&gt;here&lt;/a&gt;.&lt;/div&gt;  &lt;p style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;Sample code from the presentation can be &lt;a href="http://dl.dropbox.com/u/6037348/HTML5AndJavaScript/StructuringJavaScript.zip" target="_blank"&gt;found here&lt;/a&gt;. Check out the full-length course on the topic at &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Pluralsight.com&lt;/a&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_4911B43B.png" width="814" height="119" /&gt;&lt;/a&gt;&lt;/div&gt;  &lt;div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8372022" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/DevConnections/default.aspx">DevConnections</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category></item><item><title>Code and Slides: Getting Started Building Windows 8 HTML/JavaScript Metro Apps</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-getting-started-building-windows-8-html-javascript-metro-apps.aspx</link><pubDate>Sat, 31 Mar 2012 16:24:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8372009</guid><dc:creator>dwahlin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8372009</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/31/code-and-slides-getting-started-building-windows-8-html-javascript-metro-apps.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_26380E21.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_1A361DED.png" width="240" height="56" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This presentation is from a talk I gave at the spring 2012 &lt;a href="http://devconnections.com" target="_blank"&gt;DevConnections&lt;/a&gt; conference. It covers some of the key topics you need to know to get started building Windows 8 HTML/JavaScript Metro apps including navigation options, UI surfaces that can be used, controls, data binding and templates, and animations.&lt;/p&gt;  &lt;br /&gt;  &lt;div style="width: 595px" id="__ss_12234918"&gt;&lt;iframe height="497" marginheight="0" src="http://www.slideshare.net/slideshow/embed_code/12234918" frameborder="0" width="595" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/div&gt;  &lt;div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;   &lt;div style="padding-bottom: 12px; padding-left: 0px; padding-right: 0px; padding-top: 5px"&gt;View more of my presentations &lt;a href="http://www.slideshare.net/DanWahlin"&gt;here&lt;/a&gt;.&lt;/div&gt;    &lt;br /&gt;Sample code shown in the presentation can be &lt;a href="http://dl.dropbox.com/u/6037348/Windows8/CityRatingsDemo.zip"&gt;found here&lt;/a&gt;. A large number of samples are available in the Windows 8 SDK which can be &lt;a href="http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples" target="_blank"&gt;found here&lt;/a&gt;. &lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8372009" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>Call for Speakers – Fall 2012 ClientDev Connections</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/13/call-for-speakers-fall-2012-clientdev-connections.aspx</link><pubDate>Wed, 14 Mar 2012 02:32:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8345570</guid><dc:creator>dwahlin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8345570</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/13/call-for-speakers-fall-2012-clientdev-connections.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_6F3062E1.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_79818741.png" width="881" height="81" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://johnpapa.net/"&gt;John Papa&lt;/a&gt; and I just sent out a call for abstracts for the upcoming Fall 2012 DevConnections conference to be held in Las Vegas, NV. If you’re interested in presenting on client-side development topics such as HTML5, CSS3, JavaScript, jQuery (or another JavaScript library), Silverlight 5, Windows 8 Metro style app development, or other related topics please submit session ideas. If you know someone else who may be interested, please forward the information. Here’s the official announcement that was sent out.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Call for Speakers – Fall 2012 ClientDev Connections&lt;/h2&gt;  &lt;p&gt;We’d like to extend an invitation to submit abstracts for consideration to speak at the Fall 2012 Microsoft ClientDev Connections conference (part of DevConnections) in Las Vegas, October 29th – November 1, 2012. Pre-con workshops will be October 28th and post-con workshops will be on November 2nd. This is one of the new tracks at DevConnections focusing on client-side development technologies such as HTML5/CSS3, JavaScript technologies, Silverlight, and Windows 8 Metro-style apps.&lt;/p&gt;  &lt;p&gt;The deadline for submissions is Monday, April 2nd, 2012.    &lt;br /&gt;To submit sessions please use this URL: &lt;a href="http://www.deeptraining.com/devconnections/abstracts"&gt;http://www.deeptraining.com/devconnections/abstracts&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Please keep the abstracts under 200 words each and in one paragraph. No bulleted items or line breaks, and please use a spell-checker. Do not email abstracts, you need to use the web-based tool to submit them. &lt;/p&gt;  &lt;p&gt;Please submit AT LEAST 3 abstracts. There are are a limited number of speaker slots so it will help your chances of being selected if you submit 4 or more abstracts. Also, you are encouraged to suggest all-day pre or post conference workshops as well. We need to finalize the conference content and the track layout in just a few weeks, so we need your abstracts no later than Monday, April 2nd, 2012. No exceptions will be granted on late submissions! &lt;/p&gt;  &lt;p&gt;Topics of interest include (but are not limited to):   &lt;br /&gt;    &lt;br /&gt;* HTML5    &lt;br /&gt;* CSS3    &lt;br /&gt;* JavaScript development techniques    &lt;br /&gt;* jQuery or other script libraries    &lt;br /&gt;* Silverlight 5    &lt;br /&gt;* Windows 8 Metro-style apps    &lt;br /&gt;* XAML design concepts    &lt;br /&gt;* Anything else related to client-side development &lt;/p&gt;  &lt;p&gt;Please realize that while we want a lot of the new and the cool, it's also fine to propose sessions on the more mundane &amp;quot;real world&amp;quot; stuff as it pertains to client-side development.&amp;#160; &lt;/p&gt;  &lt;p&gt;What you will get if selected:    &lt;br /&gt;    &lt;br /&gt;* $500 per regular conference talk.    &lt;br /&gt;* Compensation for full-day workshops ranges from $500 for 1-20 attendees to $2500 for 200+ attendees.    &lt;br /&gt;* Coach airfare and hotel stay paid by the conference (up to $500 is covered for your flight)    &lt;br /&gt;* Free admission to all of the co-located conferences    &lt;br /&gt;* The adoration of attendees&lt;/p&gt;  &lt;p&gt;To repeat: the deadline for submissions is Monday, April 2nd, 2012 and the URL once again is &lt;a href="http://www.deeptraining.com/devconnections/abstracts"&gt;http://www.deeptraining.com/devconnections/abstracts&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Your continued support of DevConnections conferences is appreciated!&lt;/p&gt;  &lt;p&gt;Dan Wahlin &amp;amp; John Papa   &lt;br /&gt;Microsoft ClientDev Connections Conference Chairs    &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8345570" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/MVVM/default.aspx">MVVM</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/XAML/default.aspx">XAML</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/DevConnections/default.aspx">DevConnections</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>jQuery Tip #6 – Creating a Custom jQuery Selector</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/13/jquery-tip-6-creating-a-custom-jquery-selector.aspx</link><pubDate>Tue, 13 Mar 2012 07:06:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8343709</guid><dc:creator>dwahlin</dc:creator><slash:comments>10</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8343709</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/13/jquery-tip-6-creating-a-custom-jquery-selector.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Previous Tips:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/07/jquery-tip-1-defining-a-context-when-using-selectors.aspx"&gt;jQuery Tip #1 - Defining a Context When Using Selectors&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/08/jquery-tip-2-manipulating-the-dom-in-a-loop.aspx"&gt;jQuery Tip #2 - Manipulating the DOM in a Loop&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/16/jquery-tip-3-using-the-data-function.aspx"&gt;jQuery Tip #3 – Using the data() Function&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/26/jquery-tip-4-use-the-on-function-for-event-handling.aspx"&gt;jQuery Tip #4 – Use the on() Function for Event Handling&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2012/02/26/jquery-tip-5-using-jquery-s-end-function-to-work-with-sets.aspx" target="_blank"&gt;jQuery Tip #5 – Using jQuery’s end() Function to Work with Sets&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;   &lt;br /&gt;Selectors are a key part of jQuery and one of the features that have made it so popular over the years. If you've worked with jQuery then you've used different types of native selectors including tag name, ID, class name, and others. jQuery also provides selector extensions that add the ability to search children in a given parent by position, locate input elements, find even or odd elements, and much more. Examples of custom selector extensions in jQuery include :eq(), :hidden, :gt(), :visible, and many more. A complete list of the selector extensions built into jQuery can be found at &lt;a href="http://api.jquery.com/category/selectors"&gt;http://api.jquery.com/category/selectors&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;While most jQuery developers know about selector extensions, many aren't aware that you can write your own custom selectors quite easily. Although custom selector extensions certainly aren't required, they can be useful in situations where you find yourself writing the same type of code over and over and you want to simplify things as much as possible. For example, assume that you have the divs shown next defined in a page and you'd like to write code to display all hidden divs (this code is a bit contrived in order to demonstrate a point – I'd stick with consistently using CSS class names in a real app).    &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel hidden&amp;quot;&amp;gt;
    &lt;/span&gt;Panel 1
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;style&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color: red"&gt;visibility&lt;/span&gt;&lt;span style="color: blue"&gt;:hidden&amp;quot;&amp;gt;
    &lt;/span&gt;Panel 2
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;style&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color: red"&gt;display&lt;/span&gt;&lt;span style="color: blue"&gt;:none;&amp;quot;&amp;gt;
    &lt;/span&gt;Panel 3
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;div &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;panel&amp;quot;&amp;gt;
    &lt;/span&gt;Panel 4
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;If you wanted to show all panels that have the hidden class on them or those that have a style of display:none or visibility:hidden set then you might write code similar to the following. This code gets run as a button in the user interface is clicked. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;$(&lt;span style="color: maroon"&gt;'#showPanelsButton'&lt;/span&gt;).click(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    $(&lt;span style="color: maroon"&gt;'.panel'&lt;/span&gt;).each(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
        &lt;span style="color: blue"&gt;var &lt;/span&gt;$pnl = $(&lt;span style="color: blue"&gt;this&lt;/span&gt;);
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(($pnl.css(&lt;span style="color: maroon"&gt;'display'&lt;/span&gt;) == &lt;span style="color: maroon"&gt;'none'&lt;/span&gt;) ||
             $pnl.css(&lt;span style="color: maroon"&gt;'visibility'&lt;/span&gt;) == &lt;span style="color: maroon"&gt;'hidden' &lt;/span&gt;||
             $pnl.hasClass(&lt;span style="color: maroon"&gt;'hidden'&lt;/span&gt;)) {
            $pnl.removeClass(&lt;span style="color: maroon"&gt;'hidden'&lt;/span&gt;)
                .css({ &lt;span style="color: maroon"&gt;'display'&lt;/span&gt;: &lt;span style="color: maroon"&gt;''&lt;/span&gt;, &lt;span style="color: maroon"&gt;'visibility'&lt;/span&gt;: &lt;span style="color: maroon"&gt;'' &lt;/span&gt;});
        }
    });
});&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;While there's nothing wrong with this code, if you find yourself needing it in multiple places you'll either refactor it into a function (the preferred approach) or copy it around throughout one or more scripts. Another technique that can be used is to write a custom selector. By creating a custom selector you can encapsulate the code into a re-useable function and use it directly within your jQuery selectors.&lt;/p&gt;

&lt;p&gt;Creating a custom selector is accomplished by using jQuery's extend() function, defining the expression that needs to extended (the : character in this case), and then associating a selector name with a function that determines what nodes make it into a set and what nodes are excluded as the custom selector is used. This may sound at little complex at first glance but it's surprisingly simple once you see the pattern. The following code shows how the code shown earlier can be refactored inside of a custom selector.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;$.extend($.expr[&lt;span style="color: maroon"&gt;':'&lt;/span&gt;], {
    hiddenPanel: &lt;span style="color: blue"&gt;function &lt;/span&gt;(pnl) {
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(pnl == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;span style="color: blue"&gt;return false&lt;/span&gt;;
        &lt;span style="color: blue"&gt;var &lt;/span&gt;$pnl = $(pnl);
        &lt;span style="color: blue"&gt;return &lt;/span&gt;$pnl.css(&lt;span style="color: maroon"&gt;'display'&lt;/span&gt;) == &lt;span style="color: maroon"&gt;'none' &lt;/span&gt;||
               $pnl.css(&lt;span style="color: maroon"&gt;'visibility'&lt;/span&gt;) == &lt;span style="color: maroon"&gt;'hidden' &lt;/span&gt;||
               $pnl.hasClass(&lt;span style="color: maroon"&gt;'hidden'&lt;/span&gt;);
    }
});&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Looking through the previous code you'll see that we start by calling jQuery's extend() function and pass it the expression that we'd like to extend (: in this example) as well as an object literal that defines the custom selector name and the function that will be called once it's executed. In this example the custom selector is named &lt;i&gt;hiddenPanel&lt;/i&gt; and when it's used in a jQuery selector the function will check if the node that's passed in has its display set to none, visibility set to hidden, or if it has a CSS class on it named hidden. If any of the conditions are met the node is included in the set and returned to the caller. If the node doesn't meet any of the conditions it will be excluded.&lt;/p&gt;

&lt;p&gt;The following code demonstrates how to use the hiddenPanel custom selector: 
  &lt;br /&gt;

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;$(&lt;span style="color: maroon"&gt;'#showPanelsButton'&lt;/span&gt;).click(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    $(&lt;span style="color: maroon"&gt;'.panel:hiddenPanel'&lt;/span&gt;)
       .removeClass(&lt;span style="color: maroon"&gt;'hidden'&lt;/span&gt;)
       .css({ &lt;span style="color: maroon"&gt;'display'&lt;/span&gt;: &lt;span style="color: maroon"&gt;''&lt;/span&gt;, &lt;span style="color: maroon"&gt;'visibility'&lt;/span&gt;: &lt;span style="color: maroon"&gt;'' &lt;/span&gt;});
});&lt;br /&gt;&lt;/pre&gt;

&lt;h4&gt;
  &lt;br /&gt;Live Example&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://www.pluralsight.com/"&gt;&lt;img border="0" src="http://weblogs.asp.net/blogs/dwahlin/pluralsight.png" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re interested in learning more about jQuery or JavaScript check out my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt;, &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;Building ASP.NET MVC Apps with EF Code First, HTML5, and jQuery&lt;/a&gt;, or &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;Structuring JavaScript Code&lt;/a&gt; courses from Pluralsight. We also offer onsite/online training options for companies as well at &lt;a href="http://www.thewahlingroup.com/"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;p&gt;&lt;iframe style="width: 100%; height: 280px" src="http://jsfiddle.net/dwahlin/L2Dk5/20/embedded" frameborder="0" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The custom :hiddenPanel selector is now available to use anytime you're working with selectors. By creating a custom selector it's straightforward to look for hidden panels, get a set of nodes that match the conditions defined in the selector, and then modify the nodes. Although this simple custom selector example may not necessarily apply to your own application, knowing how custom selectors can be created and used is useful in a variety of scenarios.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8343709" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Creating Metro Style Icons with Metro Studio</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/06/creating-metro-style-icons-with-metro-studio.aspx</link><pubDate>Tue, 06 Mar 2012 15:15:49 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8328547</guid><dc:creator>dwahlin</dc:creator><slash:comments>18</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8328547</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/06/creating-metro-style-icons-with-metro-studio.aspx#comments</comments><description>&lt;p&gt;I normally don’t post about 3rd part software or giveaways but I’m really impressed with Syncfusion’s new Metro Studio product after &lt;a href="http://www.syncfusion.com/downloads/metrostudio" target="_blank"&gt;downloading it today&lt;/a&gt; (registration required). It’s includes 600 free icons and you can easily customize the icons. I don’t know how long the free offering will last but it’s worth registering to get a key while it’s available (nobody from Syncfusion asked me to post about the program by the way – I just liked it). Here’s what the program looks like (very Metro-ish):    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_5949178B.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_71C88F0E.png" width="630" height="450" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Once you download and install Metro Studio you’ll have access to all of the icons in various categories. That’s fantastic if you’re not super artistic like me since the more icons I have access to the better. What really surprised me though was the editor that’s included in Metro studio since it lets you change things like the size of the icon, padding, shape, background color, and even icon color. Everything can be done visually without having to be a graphics guru….pretty impressive.   &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_0F4A4441.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_5A99C238.png" width="634" height="456" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;In addition to being able to customize the icons, you’ll find a XAML button at the bottom of the editor if you’d like to get pure XAML (useful for Windows Phone or Windows 8 Metro apps built using XAML) and you can get a .png image by clicking the Save button which is great for HTML/JS Windows 8 Metro app developers.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_72708391.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_73E179D8.png" width="638" height="458" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Needless to say, I’m impressed. I’ve come across a lot of icon packages, but the level of customization provided and ease of use makes this little utility stand above anything else I’ve seen and lets non-graphics guys like me get different icons going quickly and easily. I don’t know anyone involved with creating the utility, but I’m really liking it and appreciate the free offer.&lt;/p&gt;  &lt;p&gt;My good friend Tim Heuer also has a nice post about Metro style icons and accessing them in Blend. &lt;a href="http://timheuer.com/blog/archive/2012/03/05/visualizing-appbar-command-styles-windows-8.aspx" target="_blank"&gt;Check it out here&lt;/a&gt;. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8328547" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>New Pluralsight Course: Building ASP.NET MVC Apps with EF Code First, HTML5, and jQuery</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/04/new-pluralsight-course-building-asp-net-mvc-apps-with-ef-code-first-html5-and-jquery.aspx</link><pubDate>Sun, 04 Mar 2012 17:40:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8324182</guid><dc:creator>dwahlin</dc:creator><slash:comments>19</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8324182</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/04/new-pluralsight-course-building-asp-net-mvc-apps-with-ef-code-first-html5-and-jquery.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_29206519.png" width="848" height="92" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I just finished up a new Pluralsight course titled &lt;strong&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;Building ASP.NET MVC Apps with EF Code First, HTML5, and jQuery&lt;/a&gt; &lt;/strong&gt;that I’m really excited about. As the title implies, the course provides an end to end look at an application built using ASP.NET MVC, Entity Framework Code First, HTML5, jQuery, and several other technologies. The application is a single-page application that loads the initial screen and then relies on Ajax calls to load data and tiles behind the scenes. Screenshots of the initial concept as well as the resulting application are shown next:&lt;/p&gt;  &lt;p&gt;&lt;img alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_522831DE.png" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;img alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_57B0B622.png" /&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;The goal of the course is to provide an end-to-end look at different technologies, show how they can be integrated together, and discuss several best practices that can be used in applications.&amp;#160; Most courses focus on a narrow topic (such as my &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt;, &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript"&gt;Structuring JavaScript&lt;/a&gt;, or &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=aspdotnet-webforms4-intro"&gt;ASP.NET Web Forms&lt;/a&gt; courses on Pluralsight.com) or only focus on getting started with technologies but don’t go into more real-world scenarios.&amp;#160; With this course, I walk through building an application from start to finish and discuss data repository classes, creating and using Model classes, ASP.NET MVC controllers and actions, converting Model objects to JSON, client-side technologies such as jQuery, JavaScript patterns, HTML5, Ajax calls, structuring C# and JavaScript code, dependency injection, plus a lot more. If you've been waiting for a course that ties everything together into one cohesive unit then this course will help you out. Here's a quick list of the key technologies that the course covers:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;HTML5 features &lt;/li&gt;    &lt;li&gt;JavaScript &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.modernizr.com/"&gt;Modernizer&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://html5boilerplate.com/"&gt;HTML5 Boilerplate&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt; along with several jQuery plug-ins &lt;/li&gt;    &lt;li&gt;&lt;a href="http://api.jquery.com/category/plugins/templates/"&gt;jQuery Templates&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/05/06/getting-started-with-the-html-5-canvas.aspx"&gt;Canvas&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;SVG &lt;/li&gt;    &lt;li&gt;JSON and AJAX technologies &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.asp.net/mvc"&gt;ASP.NET MVC&lt;/a&gt; (Controllers, Actions, and working with JSON) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=26825"&gt;Entity Framework Code-First&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff649690.aspx"&gt;Repository Pattern&lt;/a&gt; for data access &lt;/li&gt;    &lt;li&gt;&lt;a href="http://unity.codeplex.com/"&gt;Unity IoC Container&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Custom Dependency Resolvers &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/sqlserver/en/us/default.aspx"&gt;SQL Server 2008&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://nuget.org/"&gt;Nuget&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;A sample video from the course that shows the application that’s discussed throughout is shown next:    &lt;br /&gt;    &lt;br /&gt;&lt;object style="height:400px; width:512px" width="512" height="400"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/Xcp82q6L3lM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/Xcp82q6L3lM?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="512" height="400"&gt; &lt;/object&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To get the most out of the course I recommend that you have some familiarity with ASP.NET MVC and JavaScript/jQuery. All of the server-side code is written in C#. If you need a refresher on any of those technologies and others check out the following courses on Pluralsight.com:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jscript-fundamentals" target="_blank"&gt;JavaScript Fundamentals&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt; (one of my courses) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; (one of my courses) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=html5-fundamentals" target="_blank"&gt;HTML5 Fundamentals&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=html5css3-upgrade" target="_blank"&gt;Using HTML5 and CSS3&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=aspdotnet-mvc3-intro" target="_blank"&gt;Introduction to ASP.NET MVC 3&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here’s the complete course outline. If you don’t already have a Pluralsight subscription check out their &lt;a href="https://www.pluralsight-training.net/microsoft/Subscribe/Step1?isTrial=True" target="_blank"&gt;10-day free trial&lt;/a&gt; (and talk to your boss about getting one!). The course can be &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=web-development" target="_blank"&gt;found here&lt;/a&gt;. &lt;/p&gt;  &lt;br /&gt;  &lt;table class="linkContainer" width="701"&gt;&lt;thead&gt;     &lt;tr class="nolines"&gt;       &lt;th style="text-align: left; padding-left: 0px"&gt;Building ASP.NET MVC Apps with EF Code First, HTML5, and jQuery&lt;/th&gt;     &lt;/tr&gt;   &lt;/thead&gt;&lt;tbody&gt;     &lt;tr class="nolines"&gt;       &lt;td style="text-align: left; padding-left: 0px"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" id="web-development-m1-at-a-glance" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;The Account at a Glance Application&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Introduction&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Introduction to the Account at a Glance Application&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: The Account at a Glance Application&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Application Technologies&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Project Structure&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating the Application Projects&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Summary&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" id="web-development-m2-working-with-data" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Working with Data&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Introduction&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Data Technology Overview&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Creating Model Classes&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating Model Classes&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Creating a DbContext Class&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating a DbContext Class&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Database Structure&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Creating Data Repository Classes&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating Data Repository Classes&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Retrieving and Storing Financial Data&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Retrieving and Storing Financial Data&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Summary&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" id="web-development-m3-html-json-content" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Serving HTML5 and JSON Content&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Introduction&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Server-Side Technology Overview&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Creating ASP.NET MVC Controllers&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating Controllers&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating DataServiceController Actions&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Creating a Dependency Resolver&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Refactoring ModelContainer&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Disposing of Dependencies&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Using HTML5 Boilerplate in _Layout.cshtml&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Integrating HTML5 Boilerplate into _Layout.cshtmlDemo&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Working with Views&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Summary&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="cursor: pointer" id="web-development-m4-client-side-functionlity" class="module" onclick="toggleModule();"&gt;       &lt;td style="padding-left: 0px" class="title tocModule"&gt;         &lt;div class="playButton"&gt;&amp;#160;&lt;span style="margin-left: 10px"&gt;&lt;strong&gt;Client-Side Functionality&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Introduction&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Client-Side Technology Overview&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Application Scripts&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Defining Tile Layout using Object Literals&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Defining Tile Layout using Object Literals&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: The sceneStateManager Script&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Retrieving JSON Data using jQuery Ajax Functions&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Retrieving JSON using jQuery&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Interacting with Ajax calls using the Chrome Developer Tools&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Rendering JSON Data using jQuery Templates&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Using jQuery Templates&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Viewing jQuery Templates Functionality using the Chrome Developer Tools&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Charting Data with Canvas and SVG&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Canvas Fundamentals&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Rendering a Canvas Chart with Flot&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Working with SVG&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Integrating HTML5 Video&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Demo: Using HTML5 Video&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr class="tocClips"&gt;       &lt;td style="padding-left: 55px" class="clipTitle"&gt;         &lt;div&gt;&lt;a&gt;Summary&lt;/a&gt; &lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;   &lt;br /&gt;Additional courses that I’ve published for Pluralsight include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=win8-intro"&gt;Introduction to Building Windows 8 Metro Applications&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=aspdotnet-webforms4-intro"&gt;Introduction to ASP.NET 4 WebForms&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=sharepoint-features-and-solutions-by-example"&gt;SharePoint 2007 Features and Solutions by Example&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8324182" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/IE9/default.aspx">IE9</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Canvas/default.aspx">Canvas</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/EF+Code+First/default.aspx">EF Code First</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Modernizr/default.aspx">Modernizr</category></item><item><title>Looking Forward: Single Page Apps, Client-Side Databinding, Entity Change Tracking, and Windows 8</title><link>http://weblogs.asp.net/dwahlin/archive/2012/03/03/looking-forward-single-page-apps-client-side-databinding-entity-change-tracking-and-windows-8.aspx</link><pubDate>Sun, 04 Mar 2012 01:41:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8323221</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8323221</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/03/03/looking-forward-single-page-apps-client-side-databinding-entity-change-tracking-and-windows-8.aspx#comments</comments><description>&lt;p&gt;I had the opportunity to attend the MVP Summit and some other events that were also running up in Redmond, WA for Windows 8 and ASP.NET this past week and if there’s one thing I learned it’s that Microsoft’s developers definitely aren’t sitting around idly twiddling their thumbs. A slew of new technologies are on their way which adds to the fun if you’re someone who enjoys learning, being challenged, and having access to technologies that can help you be more productive. For me personally, that’s the fun of being in the development world. Change is part of the game and embracing it is key to being successful as a developer - at least in my opinion. While it’s true that not every new technology deserves attention (and I’d agree that some technologies seem to move too fast), there were several I saw that have some great potential. The good news is that they’re available to start using or experimenting with now if you’re interested.&lt;/p&gt;  &lt;p&gt;So what should you learn and how do you get started? Everything that follows is completely subjective of course, but if you’re a Web developer then knowing &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;JavaScript&lt;/a&gt; and &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=jquery-fundamentals" target="_blank"&gt;jQuery&lt;/a&gt; definitely won’t hurt you a bit. That includes developing for Windows 8. Developers skilled in JavaScript/jQuery will definitely be ahead of the game with the new technologies that are coming out. Sometimes it feels like I’m 1 out of 2 total developers on the planet that seem to actually like JavaScript (always have for some reason going back to the mid 90s), but I like the overall direction things are moving especially when I consider what it means for clients using my applications.     &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;Web Development Technologies&lt;/h2&gt;  &lt;p&gt;For Web developers, there are several technologies that I think are worthy of taking a closer look:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.asp.net/single-page-application" target="_blank"&gt;ASP.NET MVC Single Page Applications&lt;/a&gt; (client-centric application relying on JavaScript, uses Knockout and Upshot, can work on the desktop browser or on mobile devices)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.asp.net/web-api" target="_blank"&gt;ASP.NET Web API&lt;/a&gt; (new server-side API for serving different data formats to a variety of applications)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://knockoutjs.com/examples/helloWorld.html" target="_blank"&gt;Knockout&lt;/a&gt; (client-side databinding, templating, and more)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://nuget.org/packages/Upshot" target="_blank"&gt;Upshot&lt;/a&gt; (client-side data sources, tracking client-side insert/update/delete changes, accessing server APIs using Ajax)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;ASP.NET MVC Single Page Applications provide a flexible, client-centric way to build applications. They rely on ASP.NET MVC which renders the initial HTML, JavaScript libraries such as Knockout and Upshot for data binding and data access, and the ASP.NET Web API for serving and modifying data on the server. Many of the technologies could be used on their own as well in standard HTML pages. Single Page Applications add support for additional functionality that most Web applications don’t normally have including history support, deep linking, and offline applications. Check out &lt;a href="http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159" target="_blank"&gt;Steve Sanderson’s presentation&lt;/a&gt; at TechDays for a nice overview of what can be done with Single Page Applications. I’m starting work on a new course for Pluralsight that will cover the ins-and-outs of building &lt;a href="http://www.asp.net/single-page-application/an-introduction-to-spa/overview/landingpage" target="_blank"&gt;ASP.NET MVC Single Page Applications&lt;/a&gt; and using technologies like the Web API and Upshot and am really excited about the functionality Microsoft is providing in this space.&lt;/p&gt;  &lt;p&gt;If you already know JavaScript, jQuery, and related technologies then I’d highly recommend jumping into technologies like Knockout since it’s well established, adds a tremendous amount of productivity to your arsenal (two-way databinding in HTML pages anyone?), has great samples, and a large following on the Web. My good friend &lt;a href="http://johnpapa.net/" target="_blank"&gt;John Papa&lt;/a&gt; has an awesome course on everything you need to know to get started with KnockoutJS on Pluralsight that you can &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=knockout-mvvm" target="_blank"&gt;find here&lt;/a&gt;. I highly recommend it if you’d like to learn more about using Knockout in your Web applications today.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=knockout-mvvm"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_3FA0D5C9.png" width="805" height="94" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here’s a description of the course:&lt;/p&gt;  &lt;p&gt;Do you write a lot of HTML, JavaScript, and jQuery to push and pull data? Does your JavaScript seem to lack the structure and patterns of your non script code? In this course you will learn popular techniques to use data binding to bind your data to your target controls in HTML writing less code, but gaining more power. See how to consume json data, use json objects in JavaScript, and use declarative binding all by using the KnockoutJS JavaScript library. Learn how the XAML data binding paradigm has been brought to the web world with observable objects, change notifications, subscriptions, and 2 way bindings. Explore modern JavaScript patterns and practices that follow the SOLID principles, reduce errors in your code, and make code easier to maintain. After taking this course you will have a solid foundation for building robust web apps using common JavaScript patterns, MVVM, and KnockoutJS.   &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;Desktop (or Web) Development Technologies&lt;/h2&gt;  &lt;p&gt;Microsoft just released the &lt;a href="http://windows.microsoft.com/en-US/windows-8/download" target="_blank"&gt;Consumer Preview of Windows 8&lt;/a&gt; and I’ll admit I’m really excited about it – especially the opportunity that the App Store presents. I have it running on both my laptop and desktop machines at this point. Check out &lt;a href="http://www.hanselman.com/blog/HowToGuideToInstallingAndBootingWindows8ConsumerPreviewOffAVHDVirtualHardDisk.aspx" target="_blank"&gt;Scott Hanselman’s post&lt;/a&gt; on setting up a bootable VHD if you’re interested in getting it going without messing up your existing OS. See my previous post titled &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/09/17/why-i-m-excited-about-windows-8.aspx" target="_blank"&gt;Why I’m Excited about Windows 8&lt;/a&gt; for additional details on why I’m looking forward to the new OS.&lt;/p&gt;  &lt;p&gt;From a development standpoint, you have two options for building Windows 8 Metro style Apps that will be deployed in the upcoming Windows App Store:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Build XAML applications with C#, C++, VB, etc.&lt;/li&gt;    &lt;li&gt;Build HTML5/JavaScript applications&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;If you’re already building WPF or Silverlight applications then the move to XAML-based Metro Apps will be relatively painless. Sure, you’ll have to learn the new WinRT namespaces, classes, and overall API, but things map up pretty nicely with the stuff you’re already used to. I’m a big fan of XAML based on my experience with Silverlight and WPF so it’s exciting to see that the skills I already have in that area can be leveraged to build Metro Apps.&lt;/p&gt;  &lt;p&gt;If you’re building Web applications you can use your existing skills to build Metro Apps as well. That includes using HTML5, JavaScript, jQuery, and other popular libraries out there. By default, applications rely on WinJS scripts for rendering UI, performing animations, using platform controls, performing data binding, etc. but you can certainly use other libraries as well to perform a variety of tasks. Although the apps are written using HTML5 and JavaScript, they’re packaged up and can be placed in the Windows 8 App Store for consumers to download.&lt;/p&gt;  &lt;p&gt;Developers building Windows Forms, WPF, or Silverlight apps can also target the desktop mode of Windows 8 (non-Metro Apps) and existing applications are supposed to port over nicely to Windows 8 (I haven’t had a chance to validate this claim yet but everything I’ve tried over the past few days has worked perfectly). That means that various types of desktop applications can still be used just as they are on Windows XP, Vista, or Windows 7.&lt;/p&gt;  &lt;p&gt;John Papa and I put together a course on getting started &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=win8-intro" target="_blank"&gt;building Windows 8 Metro Apps&lt;/a&gt; if you’re interested in jumping into that arena that can also be found on Pluralsight.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=win8-intro"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_4C9AB5DA.png" width="822" height="96" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here’s a description of the course:&lt;/p&gt;  &lt;p&gt;Windows 8 Metro style apps provide a new opportunity for developers to interact with users and provide a more immersive experience on the desktop or on touch devices. This course covers fundamentals you need to know to get started building Metro apps quickly using Visual Studio 11. Topics covered include an overview of Windows 8 and Metro app features as well as key features that you need to know to build HTML/JavaScript or XAML/C# Metro apps.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;There’s a lot of new technology coming our way in the near future. Some of it may change how we write existing applications and some of it may go the way of the Dodo and be extinct in a few years. It’s always hard to know what technologies to tackle but I’m betting on many of the technologies I discussed here sticking around for quite awhile. While it’s not all roses, I definitely feel excited about the future of Web and Desktop development and like the overall direction that Microsoft is going.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8323221" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Windows+8/default.aspx">Windows 8</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Metro+Apps/default.aspx">Metro Apps</category></item><item><title>Video: Structuring JavaScript with the Revealing Module Pattern</title><link>http://weblogs.asp.net/dwahlin/archive/2012/02/26/video-structuring-javascript-with-the-revealing-module-pattern.aspx</link><pubDate>Mon, 27 Feb 2012 07:16:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8315761</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=8315761</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2012/02/26/video-structuring-javascript-with-the-revealing-module-pattern.aspx#comments</comments><description>&lt;p&gt;This sample video from Pluralsight’s &lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=structuring-javascript" target="_blank"&gt;Structuring JavaScript Code&lt;/a&gt; course provides an introduction to the Revealing Module Pattern and demonstrates how it can be used to convert “function spaghetti code” to more structured code that’s re-useable and easier to maintain. If you’d like additional details about using the Revealing Module Pattern as well as other patterns that can be used to structure your JavaScript code view my post &lt;a href="http://weblogs.asp.net/dwahlin/archive/2011/08/02/techniques-strategies-and-patterns-for-structuring-javascript-code-revealing-module-pattern.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;object style="height:400px; width:512px" width="512" height="400"&gt;    &lt;param name="movie" value="http://www.youtube.com/v/V_X86VyrEjc?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1"&gt;    &lt;param name="allowFullScreen" value="true"&gt;    &lt;param name="allowScriptAccess" value="always"&gt;    &lt;embed src="http://www.youtube.com/v/V_X86VyrEjc?version=3&amp;amp;feature=player_profilepage&amp;amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="512" height="400"&gt; &lt;/object&gt;  &lt;p&gt;   &lt;br /&gt; Additional courses that I’ve published for Pluralsight are shown below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=win8-intro"&gt;Introduction to Building Windows 8 Metro Applications&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=aspdotnet-webforms4-intro"&gt;Introduction to ASP.NET 4 WebForms&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=jquery-fundamentals"&gt;jQuery Fundamentals&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.pluralsight-training.net/microsoft/courses/TableOfContents?courseName=sharepoint-features-and-solutions-by-example"&gt;SharePoint 2007 Features and Solutions by Example&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8315761" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/HTML5/default.aspx">HTML5</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/JavaScript/default.aspx">JavaScript</category></item></channel></rss>

