<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://kevinhoffman.sys-con.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Latest News from Kevin Hoffman</title>
 <link>http://kevinhoffman.sys-con.com/</link>
 <description>Latest News from Kevin Hoffman</description>
 <language>en</language>
 <copyright>Copyright 2009 Ulitzer.com</copyright>
 <generator>Ulitzer.com</generator>
 <lastBuildDate>Tue, 24 Nov 2009 10:09:07 EST</lastBuildDate>
 <docs>http://backend.userland.com/rss</docs>
 <ttl>360</ttl>
<item>
 <title>Would You Like to Touch My Mono?</title>
 <link>http://kevinhoffman.sys-con.com/node/1198692</link>
 <description>At one point I was actually thinking about writing a book for .NET developers to learn Cocoa but other plans, time constraints, and life issues all got in the way. I have posted countless times comparing the worlds of Cocoa and .NET and have twice presented at Apple&#039;s WWDC comparing both the desktop and mobile programming environments of Apple and Microsoft. So you can imagine the raw, unfiltered, pure geek joy that coursed through my veins when I heard about Monotouch, a programming library coupled with an IDE (MonoDevelop + Interface Builder) that would let me write my iPhone applications using C# and the .NET Framework (the mono version).&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1198692&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 23 Nov 2009 22:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1198692</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1198692#feedback</comments>
</item>
<item>
 <title>Kindle 2 vs Nook</title>
 <link>http://kevinhoffman.sys-con.com/node/1152430</link>
 <description>Barnes &amp; Noble just recently unveiled their upcoming eReader, the Nook. On the blog of my non-techy alter-ego I&amp;#39;ve posted a comparison of the two readers that is entirely based on my own personal feelings of what is cool and what isn&amp;#39;t, so take it as opinion and certainly not as a technical review. &lt;strong&gt;&lt;a href=&quot;http://tinyurl.com/yjfyzcm&quot;&gt;Click here&lt;/a&gt;&lt;/strong&gt; to check out the blog post.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1152430&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 19 Nov 2009 06:30:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1152430</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1152430#feedback</comments>
</item>
<item>
 <title>Windows Identity Foundation (WIF) Release Candidate Is Out</title>
 <link>http://kevinhoffman.sys-con.com/node/1179445</link>
 <description>&lt;p&gt;I&amp;#39;m not sure how all this managed to slip by me, but apparently last Friday the Windows Identity Foundation Release Candidate was unleashed on the world. Now keep in mind that this is &lt;em&gt;not&lt;/em&gt; the ADFS v2 server, this is the foundational plumbing on which ADFS v2 will run. Good news, though, is that if you&amp;#39;re like me and you&amp;#39;re using WIF to build your own STS websites, then the RC will suit you just fine and you don&amp;#39;t have to wait for the ADFS v2.&lt;/p&gt;&lt;p&gt;Anyway, if you&amp;#39;d like to get your hands on some WIF action, click here for &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?familyid=DEFD2019-A61F-4327-9332-6A4B6103527A&amp;amp;displaylang=en&quot; target=&quot;_blank&quot;&gt;the download link&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;It doesn&amp;#39;t appear as though there are a lot of changes in the framework itself, though I think there are some possible breaking namespace changes but, I&amp;#39;m still downloading it so I don&amp;#39;t know at this point. Also, you might want to pick up the &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?familyid=C3E315FA-94E2-4028-99CB-904369F177C0&amp;amp;displaylang=en&quot; target=&quot;_blank&quot;&gt;Identity Training Kit&lt;/a&gt;. It has been revised and there&amp;#39;s a new installer for the samples that works on Windows 7 &lt;em&gt;that actually works and installs the SSL certs properly&lt;/em&gt;. Previous versions of the ID kit required lots of manual futzing around to get things to work properly with UAC and permissions and the whole &amp;quot;Internet Zone&amp;quot; download issue.&lt;/p&gt;&lt;p&gt;Enjoy!&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1179445&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 17 Nov 2009 13:45:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1179445</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1179445#feedback</comments>
</item>
<item>
 <title>Setting up an ASP.NET MVC 2 Application for Windows Azure</title>
 <link>http://kevinhoffman.sys-con.com/node/1186735</link>
 <description>Yesterday, Microsoft released another update to the Windows Azure SDK. This update includes a truckload of new goodies that I will be covering in additional blog posts. For this blog post, however, I want to walk you through getting an ASP.NET MVC 2 application working on Windows Azure in Visual Studio 2010 Beta 2. Now that Azure and VS2010 are finally starting to sync up, the amount of raw goodness coming out of Redmond cannot be measured.

First, install the Windows Azure SDK and the Windows Azure Tools for Visual Studio, making sure you pay attention to all of the installation details. There are lots of little hotfixes and things that you might need. Luckily, if you&#039;re running VS2010 Beta 2 on Windows 7, you have very little extra work to do beyond configuring IIS 7 for WCF HTTP activation.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1186735&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 17 Nov 2009 13:30:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1186735</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1186735#feedback</comments>
</item>
<item>
 <title>Getting the ASP.NET Providers Working on the Azure Nov 2009 CTP</title>
 <link>http://kevinhoffman.sys-con.com/node/1186938</link>
 <description>If you&#039;ve been trying to get the ASP.NET providers working on the November 2009 CTP of Windows Azure then you may have run into a snag, or a couple snags if you&#039;re using Visual Studio 2010.

First of all, if you&#039;re using Visual Studio 2010 Beta 2, then you&#039;re going to need to either up-convert the AspProviders project. For this, you want to go and grab the AspProviders (VS2008) sample from the Azure Code Samples home page. Once you&#039;ve got it, you can either compile it in Visual Studio 2008 or, if you&#039;re coding in VS2010 Beta 2, you can either reference the compiled binary directly or just up-convert the project to VS2010 Beta 2.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1186938&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 17 Nov 2009 13:30:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1186938</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1186938#feedback</comments>
</item>
<item>
 <title>Working with Table Storage on the Windows Azure </title>
 <link>http://kevinhoffman.sys-con.com/node/1186937</link>
 <description>&lt;p&gt;If you&amp;#39;ve been working with Azure for a while then you&amp;#39;ve probably spent some time using the &lt;strong&gt;StorageClient&lt;/strong&gt; &lt;em&gt;sample&lt;/em&gt; that came with previous versions of the SDK. With the November 2009 release of the SDK (the one they&amp;#39;ll be using at &lt;strong&gt;PDC 2009&lt;/strong&gt;), they have wrapped that sample up into the SDK and refactored it to fit more in line with the conventions and quality standards of a Microsoft API. As a result, some of your code will break (but not much). Queue storage and Blob storage (discussed in upcoming posts) actually have more breaking changes than table storage.&lt;/p&gt;&lt;p&gt;Table storage, under the hood, is exposed as an ADO.NET Data Service (formerly Astoria). As a result, if you&amp;#39;ve used the &lt;em&gt;System.Data.Services.Client&lt;/em&gt; library before, you&amp;#39;ve already got a leg up in interacting with Azure Storage.&lt;/p&gt;&lt;p&gt;When you&amp;#39;re working with table storage, there are a few things that you&amp;#39;re going to need. Once you&amp;#39;ve got these, you&amp;#39;re good to go:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;References to &lt;em&gt;System.Data.Services.Client&lt;/em&gt; and &lt;em&gt;Microsoft.WindowsAzure.StorageClient&lt;/em&gt; (obviously you also need a reference to service runtime if you&amp;#39;re hitting table storage from within the cloud itself... remember that you can hit table storage from the desktop too, e.g. from WPF applications).&lt;/li&gt;&lt;li&gt;Credentials. There have been some changes to the way storage client credentials work that are beyond the scope of this post, but you can still use the same accountname/account shared key pattern that you used in the past.&lt;/li&gt;&lt;li&gt;A &lt;em&gt;DataServiceContext&lt;/em&gt;. You&amp;#39;re going to need this to interact with the tables in table storage. As you&amp;#39;ll see in the code below, the pattern is to create your own context that derives from the base and exposes your tables as &lt;em&gt;IQueryable&lt;/em&gt;s. If you&amp;#39;ve ever worked with ADO.NET Data Services or Entity Framework before, this pattern should also look familiar.&lt;/li&gt;&lt;li&gt;Entity objects. Every table that you have in table storage contains arbitrary columns. In other words, if you really wanted, you could have a different schema for every row in your table. However, to work with it using the&amp;nbsp;Data Services client, each row needs to conform to a fixed schema - this fixed schema you&amp;#39;ll represent with a&amp;nbsp;regular C# class that contains the necessary partition key and row key&amp;nbsp;properties. This class also needs a parameterless constructor (required by the data services client to&amp;nbsp;reconstitute instances of that&amp;nbsp;class from the HTTP results)&lt;/li&gt;&lt;li&gt;The cloud&amp;nbsp;table client. This new class&amp;nbsp;will let you create tables and test for the existence of tables. You do not need to use this class for querying&amp;nbsp;table storage, it&amp;#39;s more of an administrative class for dealing with table storage itself.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The first thing we&amp;#39;re going to want to do is get the credentials. The new SDK allows us to dynamically determine if we&amp;#39;re running in a fabric or running as a standalone app (which allows us to build apps that we can run on-premise OR in the cloud!). Here&amp;#39;s some code I used to get the configuration settings for the account name and shared key:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;p&gt;string&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; accountKey = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;ConfigurationManager&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;.AppSettings[&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;AccountSharedKey&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;];&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; tableBaseUri = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;ConfigurationManager&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;.AppSettings[&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;TableStorageEndpoint&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;];&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;if&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; (&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;RoleEnvironment&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;.IsAvailable)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; accountName = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;RoleEnvironment&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;.GetConfigurationSettingValue(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;AccountName&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; accountKey = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;RoleEnvironment&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;.GetConfigurationSettingValue(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;AccountSharedKey&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;);&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Once you&amp;#39;ve got the account key and the account name, you can get an instance of the storage credentials and table client classes:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;p&gt;StorageCredentialsAccountAndKey&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; creds = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;StorageCredentialsAccountAndKey&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;(accountName, accountKey);&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CloudTableClient&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; tableStorage = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CloudTableClient&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;(tableBaseUri, creds);&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerContext&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; ctx = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerContext&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;(tableBaseUri, creds);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Using the table storage class, we can create a new table (if it doesn&amp;#39;t already exist):&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;p&gt;if&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; (tableStorage.CreateTableIfNotExist(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;Customers&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;))&lt;br /&gt;{ &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerRow&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; cust = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerRow&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;AccountsReceivable&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;, &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;kevin&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;);&lt;br /&gt;cust.FirstName = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;Kevin&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;;&lt;br /&gt;cust.LastName = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;Hoffman&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;;&lt;br /&gt;ctx.AddObject(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;Customers&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;, cust);&lt;br /&gt;ctx.SaveChanges(); &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Here I&amp;#39;m also using my customer context class and my customer row class (will show those shortly) in order to put a new customer into table storage. Note my use of an application name for the partition key and the username for the row key. Entire chapters of books can (and will) be written on strategies and patterns for using partition and row keys.&lt;/p&gt;&lt;p&gt;Now let&amp;#39;s say that we&amp;#39;re inside an MVC 2 controller and we want to make the list of customers available to the view. If we&amp;#39;re not doing a strongly typed view (which we should be doing unless we can&amp;#39;t help it...) then we can use code that looks like this:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;p&gt;CustomerRow&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;[] customers = ctx.Customers.ToArray();&lt;br /&gt;ViewData[&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;Customers&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;] = customers; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Now let&amp;#39;s look at the CustomerContext class:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;p&gt;public&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;class&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerContext&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; : &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;TableServiceContext&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; CustomerContext(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; uri, &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;StorageCredentials&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; creds) : &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;base&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;(uri, creds) { }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerRow&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&amp;gt; Customers&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;return&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;this&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;.CreateQuery&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerRow&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&amp;gt;(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#a31515&quot;&gt;&amp;quot;Customers&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;The CustomerRow class is just a POCO class that has a default constructor and a constructor that takes a partition key and a row key, and inherits from the &lt;strong&gt;TableServiceEntity&lt;/strong&gt; class.&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;class&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;CustomerRow&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; : &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#2b91af&quot;&gt;TableServiceEntity&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;private&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; firstName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;private&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; lastName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;private&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; userName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;private&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; applicationName;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; CustomerRow(&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; applicationName, &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;string&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; userName)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;base&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;(applicationName, userName)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ApplicationName = applicationName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UserName = userName; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; CustomerRow() : &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;base&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;() { }&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;I snipped out the rest of the class for brevity - I&amp;#39;m assuming we&amp;#39;ve all seen stock property accessors before. At this point you should be ready to roll using table storage. There is also one other benefit they gave us in November 2009 CTP - &lt;em&gt;&lt;strong&gt;you no longer need to pre-rig your database schema in your SQL 2008 database&lt;/strong&gt;&lt;/em&gt;!! The new development storage simulator accurately simulates the dynamic schema nature of the actual table storage in the cloud. I can&amp;#39;t begin to describe how many headaches this alleviates.&lt;/p&gt;&lt;p&gt;Enjoy table storage on the new Nov 2009 CTP and I&amp;#39;ll be posting similar blog posts about the new Queue storage and Blob storage clients shortly!&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1186937&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 17 Nov 2009 00:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1186937</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1186937#feedback</comments>
</item>
<item>
 <title>Installing Geneva Beta 2 on Windows7</title>
 <link>http://kevinhoffman.sys-con.com/node/1175523</link>
 <description>&lt;p&gt;Recently I installed the Beta 2 version of &amp;quot;Geneva&amp;quot;, or ADFS 2.0. All of my machines are now Windows 7&amp;nbsp;machines, including just about all of my VHDs and virtual machines. The only time I use Win2k8 R2 is when the product I&amp;#39;m installing specifically requires me to do that. So when I installed Geneva on my Win7 box, I thought everything would be fine.&lt;/p&gt;&lt;p&gt;Then I rebooted. The &amp;quot;Modify STS Reference...&amp;quot; and &amp;quot;Update federation metadata&amp;quot; menu items that are supposed to be added to the list of available options on an ASP.NET web application were gone. They were there before I rebooted but they were gone after. I also noticed something funny with the Identity training kit install. Every single directory and file in there was marked as &amp;quot;read only&amp;quot;. I would unset the read-only flag, right click the file, get properties, and sure enough, &lt;em&gt;it was still set to read only&lt;/em&gt;. WTF?&lt;/p&gt;&lt;p&gt;Turns out that when I download files from the big bad scary internet, Windows 7 automatically flags them as &amp;quot;bad content&amp;quot; and they are blocked. The permissions of those files are significantly less than those of files I put onto my computer via DVD or whatever. This is actually as it should be, and it&amp;#39;s designed to keep me from doing horribly bad things to my computer. &lt;/p&gt;&lt;p&gt;I uninstalled the Geneva SDK and the Identity Training Kit. I then right-clicked each of the &lt;em&gt;.msi&lt;/em&gt; files, chose Properties and then clicked the magic &lt;em&gt;&lt;strong&gt;Unblock&lt;/strong&gt;&lt;/em&gt; button. After this, when I installed the Framework SDK, the Visual Studio extensions remained after reboot, and the files created by the identity training kit didn&amp;#39;t have weird permission problems and the certificates installed by the lab set up actually bound to the SSL port properly.&lt;/p&gt;&lt;p&gt;So, the moral of the story is this: If you&amp;#39;re going to install an MSI that you downloaded from a trusted source (like MSDN or Microsoft Downloads or h0tpr0n.com), unblock it before you install just to make sure you don&amp;#39;t run into any goofy permission issues.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1175523&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 05 Nov 2009 08:38:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1175523</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1175523#feedback</comments>
</item>
<item>
 <title>Why we&#039;re all NOT going to die on December 21st, 2012.</title>
 <link>http://kevinhoffman.sys-con.com/node/1173567</link>
 <description>&lt;p&gt;Unless you&amp;#39;ve been living under a rock for the past couple of months, you&amp;#39;ve probably not been able to escape the movie trailers, hype, and even SyFy channel (yes, SYFY channel..that should TELL YOU SOMETHING) specials regarding the Mayan &amp;quot;prediction&amp;quot; that the world will end in 2012.&lt;/p&gt;&lt;p&gt;First, some background on the Mayan calendar. The &amp;quot;long count&amp;quot; Mayan calendar is based, basically (I am oversimplifying a little bit), on interlocking wheels. You can think of these as gears where as the days pass, a bigger gear of seasons pass, which then slowly causes another bigger gear to pass. Finally, you end up with a gear that marks the passing of ages that marks the passage of a total of 26,000 years. There are 13 of these ages on the &amp;quot;big gear&amp;quot;. &lt;/p&gt;&lt;p&gt;The Mayan long count calendar reaches 13.0.0.0.0 on December 21st, 2012. Does this mean that the world is going to come to an end on that date? Does this mean that a huge apocalypse is going to rip the earth apart in huge explosions and other hollywood-like demolitions? Are we all going to cease to exist as time itself comes to a crashing halt?&lt;/p&gt;&lt;p&gt;UM. &lt;strong&gt;&lt;em&gt;&lt;u&gt;NO&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;What we&amp;#39;re looking at here is the Mayan equivalent of the Y2K problem. The Mayans, when constructing their calendars and the wheels/gears/ whatever they call them - constructed them to mark the passing of 26,000 years. When you think about how long that is, its a ridiculous amount of time. They probably said to themselves, &amp;quot;Nobody is ever going to need more than 26,000 years on a calendar.&amp;quot; Well, let&amp;#39;s see. Where have we heard that mistake before? Oh yeah: &lt;em&gt;No one is ever going to need 4 digits to store a year in a piece of computer software&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;So if you&amp;#39;re smart, you&amp;#39;ll get people to give you all their worldy possessions on December 20th, 2012. Then, on December 22nd, 2012 - sell them all back at a premium. Call it the &amp;quot;sucker surcharge&amp;quot;, a fee for being such a gullable moron that they believed the world was going to end because a civilization &lt;em&gt;without the ability to predict the future&lt;/em&gt; basically ran out of storage space in their gear-based calendar system.&lt;/p&gt;&lt;p&gt;I personally am thinking of having an &amp;quot;end of the world&amp;quot; party on December 21st, 2012. I had one on Jan 1, 2000 and I&amp;#39;ll be there laughing at the mindless masses as they cringe in expectation of doomsday. I should be able to pick up some dirt cheap real estate, too.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1173567&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 04 Nov 2009 16:02:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1173567</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1173567#feedback</comments>
</item>
<item>
 <title>Something Wicked This Way Comes - Breaking Changes for .NET Services in Azure</title>
 <link>http://kevinhoffman.sys-con.com/node/1169534</link>
 <description>&lt;p&gt;If you want the full gory details, check out the .NET Services team &lt;a href=&quot;http://blogs.msdn.com/netservicesannounce/archive/2009/10/30/the-net-services-november-2009-ctp-breaking-changes-announcement-and-scheduled-maintenance.aspx&quot;&gt;blog post here&lt;/a&gt;. What follows below are some of the things that I think are most crucial to understand both for new developers and for developers unfortunate enough to be in a position of having to migrate a lot of code. Quite possibly the single most important thing to note is this:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;em&gt;If you bought a book on Windows Azure that has already been released or will be released within the next month or two, it is out of date and completely irrelevant. PDC (along with the changes I&amp;#39;m going to outline below) will substantially change all of the Azure offerings.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I&amp;#39;ve trimmed a little bit because some of the breaking changes are fairly minor and don&amp;#39;t have too much impact on developers. Here is the list:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Portal address change. This is an easy enough fix and a simple find-and-replace if you&amp;#39;ve got any code that uses that portal address.&lt;/li&gt;&lt;li&gt;Solution region migration. Some solutions when migrated to the new version of .NET Services might end up hosted in a different geographical region than before. This isn&amp;#39;t all that big of a deal (for most of us).&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Queues Are Being Removed&lt;/strong&gt;. This is &lt;em&gt;huge&lt;/em&gt;. In the current version of .NET Services, you can use queues as a way of sending reliable, durable messages between the cloud and on-premise applications without the other endpoint being physically connected. This is a huge change. A new concept called &lt;em&gt;Message Buffers&lt;/em&gt; are being introduced. I don&amp;#39;t have all that much information on them but it looks as though the message buffers are essentially transient queues. You send a message to a buffer and it&amp;#39;ll hang out in the buffer while the other end steadily pulls messages out of the buffer. A key point they make is that if you&amp;#39;re looking for durable, reliable, &lt;em&gt;persisted&lt;/em&gt; messages between service bus endpoints, you might want to look at using Azure Storage. As painful as it is to see queues go, I think this is a good move. Azure storage already has Queues, and they are robust and powerful. If the reason you were using Queues was to keep from overloading an endpoint with too many messages, the message buffer is your new tool of choice. If you were using Queues so that you could send messages while the polling end was offline, then you&amp;#39;re probably going to need to concoct something involving an Azure Storage queue.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Routers Are Being Removed&lt;/strong&gt;. This is also &lt;em&gt;huge&lt;/em&gt;, though slightly less huge than queues. The router concept never really &amp;quot;gelled&amp;quot; with me to begin with - I couldn&amp;#39;t quite figure out how best to use it. Now that they&amp;#39;re being removed and there will be some samples on how to do things like load balancing and targeted delivery, architectural decisions in this area should become easier to make.&lt;/li&gt;&lt;li&gt;Relay Bindings are now secure (HTTPS) by default. You can override this behavior but there&amp;#39;s very little reason to do so unless you are specifically trying to get your security information stolen.&lt;/li&gt;&lt;li&gt;Service Namespace. Now instead of the solution name being the hostname of your *.servicebus.windows.net server, you will be able to choose something called the service namespace and have that be the hostname prefix, e.g. (namespace).servicebus.windows.net. This has low impact but is actually very useful.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;TransportClientCredentialType&lt;/strong&gt; is being limited. Transport client credentials can no longer include X509 certificates, username/password combinations, or CardSpace cards.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;TcpRelayConnectionMode.Direct&lt;/strong&gt; will be removed. This bugs me a little bit because way WAY back when Azure was first unveiled to the public, I remembered talking to someone who said that we&amp;#39;d be able to use the service bus to establish direct connections between two peers both of whom were behind firewalls. This is no longer a possibility, but I can see the reasoning behind it and, quite frankly, my particular use case for this feature was really niche-y.&lt;/li&gt;&lt;li&gt;Service publishing feed now matches transport. This is handy and makes things a little more straightforward. For those who don&amp;#39;t know, a service publishing feed is basically an Atom feed that shows all of the endpoints on your service bus service that have indicated they want their presence known publicly. In other words, I could hit the service publishing feed and get a list of all connected endpoints. That one ability is &lt;em&gt;ridiculously&lt;/em&gt; powerful and is not getting nearly enough hype for the number of scenarios it enables.&lt;/li&gt;&lt;li&gt;WSHttpRelayBinding has been removed. I&amp;#39;m not gonna miss this one bit as I never used it. &lt;/li&gt;&lt;li&gt;WS2007FederationHttpRelayBinding removed. Again, not gonna miss it.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Solution credentials replaced with issuer credentials in Access Control Service&lt;/strong&gt;. This one is also quite big. Today, you can use a username/password combo, an X509 cert, or a CardSpace card to &lt;em&gt;request tokens from the STS&lt;/em&gt;. As of Thursday, you&amp;#39;re going to need an issuer credential (issuer key and issuer name). In addition, we&amp;#39;re going to have to upload X509 certs to the portal to allow for SAML token requests. I will probably be doing a blog post on this once I get more information because this one is totally game changing and will halt development workflow as it stands now and totally change it after Thursday.&lt;/li&gt;&lt;li&gt;&lt;h2 style=&quot;line-height: normal; margin: 10pt 0in 0pt&quot;&gt;&lt;font face=&quot;Cambria&quot; size=&quot;4&quot;&gt;WS-Trust STS replaced with Web Resource Authorization Protocol (WRAP) STS&lt;/font&gt;&lt;/h2&gt;&amp;nbsp; - Yes, I made this one gigantic. Why? &lt;em&gt;Ding dong the witch is dead! The wicked witch is dead!&lt;/em&gt; WRAP is RESTful people. WS-Trust is EVIL people. Enjoy. We&amp;#39;ve all just been given a shiny cupcake with a frosting of &lt;em&gt;awesome&lt;/em&gt; on top.&lt;/li&gt;&lt;li&gt;Access Control Service data &lt;em&gt;&lt;strong&gt;will not be migrated&lt;/strong&gt;&lt;/em&gt;. This means if you&amp;#39;re one of those crazy early adopters and you&amp;#39;ve already written a complete app on the existing ACS - &lt;em&gt;get your data backed up and saved somewhere now. It will be deleted on Thursday morning!&lt;/em&gt;&lt;/li&gt;&lt;li&gt;Access Control Management Portal is being replaced with a command-line tool. I know some of you might be thinking, &lt;em&gt;dammit! &lt;/em&gt;But I see this as a good thing. It&amp;#39;s an absolute pain in the ass to stop what I&amp;#39;m doing and click through 8 billion links (including the 500,000,000,000,000 redirects involved with a Windows Live ID login) just to go tweak some small setting. I could probably take 20 minutes to rig up a couple .cmd files to do regular ACM tasks that are specific to my app and be done with it. This is going to be a big productivity gain, even though we lose some flashy web-based GUI.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here&amp;#39;s the bottom line: &lt;/p&gt;&lt;p&gt;&lt;em&gt;Windows Azure (including Azure Storage, SQL Azure, and .NET Services) is maturing. It is moving away from being an experiment and moving toward a product that can sustain regular income and regular usage and the 90% customer usage scenarios. As a result, they&amp;#39;re going to break changes and add features and shut off lame or ineffective or almost-never-used features.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Can&amp;#39;t wait to get my hands on the new bits Thursday.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1169534&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 02 Nov 2009 08:36:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1169534</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1169534#feedback</comments>
</item>
<item>
 <title>LINQ to SQL and Entity Framework on top of SQL Azure</title>
 <link>http://kevinhoffman.sys-con.com/node/1163900</link>
 <description>As mentioned in my &lt;a href=&quot;/sqlazure_maintenance.htm&quot; target=&quot;_blank&quot;&gt;previous blog post&lt;/a&gt;, you don&amp;#39;t get full designer support on SQL Azure within SQL Server Management Studio. In addition, you don&amp;#39;t get designer support for LINQ to SQL or Entity Framework, either. So what do you do if you want to take advantage of these awesome object mapping tools but the designers don&amp;#39;t work directly against the cloud?&lt;/p&gt;&lt;p&gt;Conveniently enough, if you follow the tips in the previous blog post, you would have already created a local copy of your SQL Azure database. The &amp;quot;trick&amp;quot; (not really a trick at all, just not immediately obvious) is to point your EF or LINQ to SQL Visual Studio projects at your local database. This will give these mappers the schema and relationship information they need in order to create the appropriate conceptual&amp;lt;-&amp;gt;relational mappings.&lt;/p&gt;&lt;p&gt;For LINQ to SQL, all you need to do is replace the connection string that it adds to your &lt;em&gt;app.Config&lt;/em&gt; file with the connection string supplied by the &lt;em&gt;sql.azure.com&lt;/em&gt; portal. Remember to include your password in this connection string because the portal copies a version of this string to your clipboard with the password of &lt;em&gt;myPassword&lt;/em&gt;. At this point you should also be thinking to yourself, &amp;quot;&lt;em&gt;Wow, I just put a cleartext password in a .config file. It&amp;#39;s a really good thing that this code isn&amp;#39;t going to sit on someone&amp;#39;s desktop and will be protected in the cloud.&lt;/em&gt;&amp;quot; &lt;/p&gt;&lt;p&gt;With Entity Framework, the connection string is a little more complicated. There&amp;#39;s some entity stuff in there that points to the various model definition files in the project and then there&amp;#39;s an embedded connection string. Replace the embedded connection string (take care to maintain the escaping of nested quotes, etc) with the one the SQL Azure portal supplied and change the password to reflect the right password.&lt;/p&gt;&lt;p&gt;At this point you should have been able to generate a model from your &lt;em&gt;local&lt;/em&gt; database and then change the connection string so that the actual data comes from the &lt;em&gt;cloud&lt;/em&gt; database. It might seem a little inconvenient but it isn&amp;#39;t really all that bad. It just adds a few extra steps to your SDLC when you need to change the schema of a live application.&lt;/p&gt;&lt;p&gt;The feeling I got when I ran my first LINQ to Entities query against a cloud-based SQL Server database was overwhelming. Sure I love new technology as much as the next guy, but the possibilities that are being opened for developers by Windows Azure and cloud computing in general are so numerous it&amp;#39;s hard to contain myself. &lt;/p&gt;&lt;p&gt;This is a &lt;em&gt;damn good time&lt;/em&gt; to be a developer.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1163900&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Sat, 31 Oct 2009 18:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1163900</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1163900#feedback</comments>
</item>
<item>
 <title>Creating and Manipulating Your SQL Azure Database</title>
 <link>http://kevinhoffman.sys-con.com/node/1163899</link>
 <description>&lt;p&gt;So after the long and torturous wait, you&amp;#39;re now in the SQL Azure CTP and you are ready to get the ball rolling with your fabulous, shiny new cloud-based SQL database server. Now what? Well, the first thing you&amp;#39;re going to need to do is create a database.&lt;/p&gt;&lt;p&gt;To do that, you&amp;#39;ll go to &lt;strong&gt;sql.azure.com&lt;/strong&gt; and follow the directions to sign in - if you haven&amp;#39;t already supplied the invite key you&amp;#39;ll need to supply it after you sign in the first time. Select your project and click on it. At this point you&amp;#39;ll see a pretty sparse management screen with two tabs: &lt;em&gt;databases&lt;/em&gt; and &lt;em&gt;firewall settings&lt;/em&gt;. On the database tab, create a new database (its up to you whether you create a 1GB or a 10GB max database). After you&amp;#39;ve created it, you&amp;#39;ll be able to click the &lt;em&gt;Connection Strings&lt;/em&gt; button to get an ADO.NET connection string for the database as well as an ODBC connection string.&lt;/p&gt;&lt;p&gt;That&amp;#39;s great, but how do you manage the schema? Can you just fire up SQL Server Management Studio (SSMS) and right-click on the &amp;quot;Tables&amp;quot; node and create new tables the old fashioned way? Unfortunately, no. You cannot connect to SQL Azure directly with SSMS the way you can to a regular SQL Server instance.&lt;/p&gt;&lt;p&gt;To connect to SQL Azure with SSMS:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Open SSMS (this part should be pretty obvious)&lt;/li&gt;&lt;li&gt;When you are prompted to connect to a database, &lt;em&gt;&lt;strong&gt;cancel that dialog&lt;/strong&gt;&lt;/em&gt;.&lt;/li&gt;&lt;li&gt;You should be left with an empty management console. Click &lt;em&gt;&lt;strong&gt;New Query&lt;/strong&gt;&lt;/em&gt;.&lt;/li&gt;&lt;li&gt;For the server name, take the fully qualified host name from your SQL Azure connection string. It should look something like &lt;em&gt;(blah).database.windows.net&lt;/em&gt;.&lt;/li&gt;&lt;li&gt;Choose SQL Server Authentication. Supply the username and password that you used for your database. Parts of this information should also be visible on your connection string.&lt;/li&gt;&lt;li&gt;Click on the &lt;em&gt;Options&lt;/em&gt; button on the bottom right of the dialog box&lt;/li&gt;&lt;li&gt;Set the database name, manually, to the name of your database. It will not show up in the drop-down list.&lt;/li&gt;&lt;li&gt;Force the network protocol to be TCP/IP (this step may not be necessary, but I do it out of habit)&lt;/li&gt;&lt;li&gt;Make sure Server type is set to &lt;em&gt;Database engine&lt;/em&gt; (this is the default, but might not be if you use SSMS for more than your average bear)&lt;/li&gt;&lt;li&gt;Now you can click &lt;em&gt;Connect&lt;/em&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;At this point, if everything worked well, you should &lt;em&gt;&lt;strong&gt;FAIL&lt;/strong&gt;&lt;/em&gt; to connect to SQL Azure :) You should get some horrid message about a connection from your public IP address not being allowed. This is because this version of SQL Azure has a built-in firewall and, by default, it doesn&amp;#39;t allow anything through.&lt;/p&gt;&lt;p&gt;Go back to the &lt;em&gt;sql.azure.com&lt;/em&gt; portal and click on the &lt;em&gt;Firewall Settings&lt;/em&gt; tab. Check the &lt;em&gt;Allow Microsoft Services to Access this server&lt;/em&gt; box. Click the button to add a new record. At this point it will conveniently show you what it thinks your public IP is so you can create a new rule to allow your IP through. Keep in mind this is &lt;em&gt;only&lt;/em&gt; required to allow your home computer to access your SQL Azure server. If you have checked the &lt;em&gt;Allow Microsoft Services...&lt;/em&gt; checkbox, then connections from within the Azure fabric (like an ADO.NET call from inside an ASP.NET app in an Azure Web Role) will pass through the firewall unhindered. This firewall is specifically to keep the communication safe and give you a &amp;quot;DMZ-like&amp;quot; experience where only the people (IPs) you trust will be able to hit that server from outside the Azure cloud fabric.&lt;/p&gt;&lt;p&gt;Now, after adding the firewall rule, you will &lt;em&gt;need to wait up to 15 minutes or more&lt;/em&gt;. When I did it, it took over 20 minutes. The reason is that the portal where you hit the submit button is not the same physical machine as your SQL Azure server. It takes a few minutes for your new firewall rule to make it over to the actual data center where your SQL Azure server has been provisioned (at least that&amp;#39;s my best guess to explain this delay). So don&amp;#39;t be alarmed if 10 seconds after you add the firewall rule you still can&amp;#39;t get into your database.&lt;/p&gt;&lt;p&gt;Now you are free to write T-SQL until you are blue in the face. What&amp;#39;s that, you don&amp;#39;t love hand-writing T-SQL schema change scripts without any assistance from an IDE? Neither do I. This is why I created a Visual Studio 2008 &amp;quot;Database Project&amp;quot; that references a &lt;em&gt;local database with the same schema as the one I want to have in the cloud&lt;/em&gt;. This is useful for multiple reasons. The biggest of which is that with a &amp;quot;Database project&amp;quot; I can version control my scripts. Secondly, I automatically gain the benefit of a local development copy of my database. Finally, this allows me to, from within VS, right-click any schema element and script it into the project. I can then open that script, &lt;em&gt;do some cleaning up&lt;/em&gt;, and then execute that script in the aforementioned SSMS query window. The &lt;em&gt;cleaning up&lt;/em&gt; I&amp;#39;m referring to means stripping out the plethora of extraneous options on the ends of the &lt;em&gt;CREATE TABLE&lt;/em&gt; statements and things like that. A lot of those options aren&amp;#39;t available in SQL Azure so just strip them out after you script the table, proc, view, whatever. It&amp;#39;s a pain in the butt, but it&amp;#39;s certainly better than having to hand-craft all that T-SQL if you aren&amp;#39;t into that sort of thing. I know some developers that like to get all kinky with their T-SQL and would never let VS script it for them. Me, I like to wear protective gear when I talk to the database schema so letting VS give me a head start &lt;em&gt;suggestion&lt;/em&gt; as to the script I should run on SQL Azure works just fine for me.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1163899&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 29 Oct 2009 11:45:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1163899</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1163899#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1169533</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1169533&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1169533</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1169533#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1175522</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1175522&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1175522</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1175522#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1159504</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1159504&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1159504</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1159504#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1173566</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1173566&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1173566</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1173566#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1179444</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1179444&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1179444</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1179444#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1163898</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1163898&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1163898</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1163898#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1198691</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1198691&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1198691</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1198691#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1197338</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1197338&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1197338</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1197338#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1197047</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1197047&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1197047</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1197047#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1193959</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1193959&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1193959</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1193959#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1193509</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1193509&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1193509</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1193509#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1189358</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1189358&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1189358</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1189358#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1186986</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1186986&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1186986</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1186986#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1186936</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1186936&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1186936</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1186936#feedback</comments>
</item>
<item>
 <title>Client-Side Validation with jQuery, DataAnnotations, MVC 2, and VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1186734</link>
 <description>&lt;p&gt;Anytime a feature of a framework gives me something for free that I don&amp;#39;t need to manually implement I&amp;#39;m a happy camper. One such feature of ASP.NET MVC 2 is jQuery client-side validation. The reason I like this is that unlike other jQuery frameworks, where you have to write the jQuery yourself - you don&amp;#39;t need to do that with MVC 2. &lt;/p&gt;&lt;p&gt;Instead of having to maintain simple validation logic in two places (your business classes and your jQuery code), you can now use the Data Annotations attributes and metadata &amp;quot;buddy&amp;quot; classes to decorate your models. Those decorated models will &lt;em&gt;automatically&lt;/em&gt; generate the appropriate jQuery code to enforce all of your validation rules on the client side before the form is ever submitted. Let&amp;#39;s see how this works.&lt;/p&gt;&lt;p&gt;First, we need a model class. Let&amp;#39;s do something simple like Customer:&lt;/p&gt;&lt;pre&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Age { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;This is great. I love the fact that it doesn&amp;#39;t look ugly and view developers can look at it and immediately know what fields are available and they don&amp;#39;t need to sift through a pile of persistence garbage or validation logic. You might have noticed that I&amp;#39;ve made this class partial. The reason I&amp;#39;m doing this is because I&amp;#39;m going to create another file called &lt;strong&gt;Customer.metadata.cs&lt;/strong&gt;. There are other samples on the web that don&amp;#39;t do this, but I like cleanly separating the &lt;em&gt;definition &lt;/em&gt;of my model from the &lt;em&gt;validation logic&lt;/em&gt; for that model. Here&amp;#39;s a look at my Customer.metadata.cs file:&lt;/p&gt;&lt;pre&gt;[MetadataType(typeof(CustomerMetaData))]&lt;br /&gt;public partial class Customer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class CustomerMetaData&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [Required(ErrorMessage=&amp;quot;You must supply a name for a&amp;nbsp;customer.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [StringLength(50, ErrorMessage = &amp;quot;A customer name cannot exceed 50 characters.&amp;quot;)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;What I&amp;#39;ve done here is used a metadata &amp;quot;buddy class&amp;quot; (that&amp;#39;s what posts from Scott Guthrie and Scott Hanselman have been calling them, so I&amp;#39;m sticking with convention here). This buddy class is a placeholder for all my validation logic attributes and the runtime will then merge all this stuff onto the actual model. MVC 2 will then examine the model and , with a few lines of code in the view, generate the appropriate jQuery client-side validation logic.&lt;/p&gt;&lt;p&gt;In your view code, add the following 3 script declarations:&lt;/p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/jquery.validate.min.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;text/javascript&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;&gt;src&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;=&amp;quot;../../Scripts/MicrosoftMvcJQueryValidation.js&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#800000&quot;&gt;script&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&lt;font face=&quot;Consolas&quot; size=&quot;2&quot; color=&quot;#0000ff&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Finally, somewhere before the start of your form tag, add the following markup to the view code:&lt;/p&gt;&lt;pre&gt;&amp;lt;% Html.EnableClientValidation(); %&amp;gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;This will invoke the code that reads through the strongly typed model for your view, figures out all of the validation logic that applies, and generates the appropriate jQuery code.&lt;/p&gt;&lt;p&gt;While you could write your own jQuery validation code if you felt like it, using data annotations and MVC 2, you no longer have to maintain your validation logic in two places. The attributes apply to a single view model and all you have to do is change one of those attributes and the generated jQuery code will change as well. This is a &lt;em&gt;huge&lt;/em&gt; timesaver and promises to dramatically increase overall productivity of developers building large-scale MVC 2 applications, especially LOB apps with lots of data entry forms.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1186734&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1186734</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1186734#feedback</comments>
</item>
<item>
 <title>Binary Serialization and Azure Web Applications</title>
 <link>http://kevinhoffman.sys-con.com/node/1123950</link>
 <description>You might be thinking, pfft, I&#039;m never going to need to use Binary Serialization...that&#039;s old school. And you might be right, but think about this: Azure Storage charges you by how much you&#039;re storing and some aspects of Azure also charge you based on the bandwidth consumed. Do you want to store/transmit a big-ass bloated pile of XML or do you want to store/transmit a condensed binary serialization of your object graph?&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1123950&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Sun, 25 Oct 2009 02:15:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1123950</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1123950#feedback</comments>
</item>
<item>
 <title>Templated Helpers in ASP.NET MVC 2 (VS2010 Beta 2 Version)</title>
 <link>http://kevinhoffman.sys-con.com/node/1156125</link>
 <description>Templated Helpers are one of the new features in ASP.NET MVC 2. The other day, Visual Studio 2010 Beta 2 came out and some of you may have noticed that it comes pre-equipped with a beta release of ASP.NET MVC 2. In short a templated helper is a way of using various combinations of implicit and explicit rules to automatically place partial controls wherever particular data types need to appear, either in edit mode or display mode.

So let&#039;s say you have a DateTime property on your model called MeetingDate. Rather than make every single view write its own (potentially contrasting!) code to render dates in view mode and in edit mode, you can now do something like this:&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1156125&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Fri, 23 Oct 2009 09:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1156125</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1156125#feedback</comments>
</item>
<item>
 <title>ADO.NET Data Services Projections Makes Sliced Bread Jealous</title>
 <link>http://kevinhoffman.sys-con.com/node/1139680</link>
 <description>The other day I ran into a blog entry from the Astoria team discussing the &lt;em&gt;projections&lt;/em&gt; feature of the 1.5 CTP2 version of the product. If you&amp;#39;re not familiar with ADO.NET Data Services (formerly codenamed &lt;em&gt;Astoria&lt;/em&gt;), it&amp;#39;s basically a layer that you can put on top of an Entity Data Model and it will expose that model as a RESTful service. The URL format for this RESTful service is quite flexible, allowing you to select individual rows, perform filters, sorts, and many other things.&lt;/p&gt;&lt;p&gt;One of the new things that you can now do server-side via the new CTP2 URL syntax is projections. Projections actually allow you to control the shape of the output coming back. You can specifically choose which properties on the entity you want. Even more awesome is that this can be controller hierarchically. So if you bring back an Order entity and you include all of the OrderItem entities for that order, you can tell the server that you only want the customer for the Order and you only want Quantity and Price for the order items.&lt;/p&gt;&lt;p&gt;To perform a projection on the URL, you just use the $select parameter, like this:&lt;/p&gt;&lt;pre&gt;blah.svc/Orders?$select=OrderID,Quantity,Price&lt;/pre&gt;&lt;p&gt;And to control the shape of hierarchical data:&lt;/p&gt;&lt;pre&gt;blah.svc/Orders?$select=OrderID,Quantity,OrderItems/Price,OrderItems/Quantity&amp;amp;$expand=OrderItems&lt;/pre&gt;&lt;p&gt;At this point when I saw this I started having convulsions of pure joy. The main reasons being that every ADO.NET Data Services URL query will output either AtomPub or JSON. This means I can get only the columns I need and give them to my Ajax calls. Then I noticed that support for the new projections is actually in the Astoria client library as well, allowing me to write the following query:&lt;/p&gt;&lt;pre&gt;var q = from order in ctx.Orders&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where order.Price &amp;gt; 300&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderby order.Price descending&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select new { Price = order.Price, Quantity = order.Quantity };&lt;/pre&gt;&lt;p&gt;This will translate into an Astoria query that filters, sorts, AND projects all on the server side, leaving me with a network footprint that only transmits the information I want and nothing else. This is a godsend if you have entities with huge amounts of columns but each individual query might only need to use 1 or 2 of those columns at a time.&lt;/p&gt;&lt;p&gt;And now, if this wasn&amp;#39;t ridiculous enough, you can actually perform updates using the projected objects, AND those updates will ONLY transmit the information necessary. For example, if I only want to change an order&amp;#39;s price and I got the price from a projection, I don&amp;#39;t need to carry the entire order payload across the wire in order to commit the change:&lt;/p&gt;&lt;pre&gt;order = q.First();&lt;br /&gt;order.Quantity = order.Quantity + 42;&lt;br /&gt;svc.UpdateObject(order);&lt;br /&gt;svc.SaveChanges();&lt;/pre&gt;&lt;p&gt;This will figure out that the only thing changing is the Quantity field and it will ONLY send that information. After discovering the combination of projections and the efficient round-trips of Astoria, this is when my head exploded.&lt;/p&gt;&lt;p&gt;If you have a multi-tier scenario and you&amp;#39;re using an Entity Data Model (EDM), then you should definitely look into using ADO.NET Data Services to expose that model via services because now with projections, you can really do some unbelievable stuff. All that garbage code you used to have to generate to convert between DTOs and ViewModels and Entities and back again? You can delete ALL of that crap.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve said it before but the folks working on ADO.NET Data Services deserve a medal. If you see a member of that team, buy them a beer. You have no idea how ridiculously complicated and difficult it is to write code that supports arbitrary projections like this. I&amp;#39;m pretty sure every time you run an Astoria query with projections, an Angel gets its wings.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1139680&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 21 Oct 2009 09:30:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1139680</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1139680#feedback</comments>
</item>
<item>
 <title>The Origin of Stupidity</title>
 <link>http://kevinhoffman.sys-con.com/node/1145086</link>
 <description>So apparently Kirk Cameron and a buddy of his are continuing their campaign of lies and outright stupidity because things like common sense, science, and cold hard fact threaten their fragile hold on sanity. Ordinarily I might on on a huge rant about this but everything I could say, the woman in this video says much more eloquently than I could. This is a must-watch.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1145086&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 21 Oct 2009 09:30:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1145086</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1145086#feedback</comments>
</item>
<item>
 <title>Get Your Red Hot VS2010 Beta 2</title>
 <link>http://kevinhoffman.sys-con.com/node/1150069</link>
 <description>Visual Studio 2010 Beta 2 is now available to MSDN subscribers and will be available to the public at large late next week. The list of stuff that is awesome and worth checking out in VS2010 Beta 2 is too long and ridiculously in-depth for me to cover here. Some of the big things that affect me right off the bat are the following:&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1150069&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 21 Oct 2009 09:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1150069</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1150069#feedback</comments>
</item>
<item>
 <title>Using ASP.NET MVC Action Filters to Declare Reference Data for Views</title>
 <link>http://kevinhoffman.sys-con.com/node/1130225</link>
 <description>When we all build websites, usually we&#039;re concerned with figuring out how we&#039;re going to get the major entities into the view. We want to know how we&#039;re going to handle the shopping cart or how we&#039;re going to get the customer record onto the page, etc. But, one of the little details that almost always comes back to bite us in the ass is the use of reference data. Reference data is data that rarely changes, is frequently queried, and shows up in multiple places throughout the application. This might be anything from the list of companies currently trading on a particular stock market if you&#039;re building a financial web application or things like the list of countries, states, cities, counties, tax rules, and shipping tables if you&#039;re doing fulfillment of orders online.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1130225&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Fri, 02 Oct 2009 12:17:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1130225</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1130225#feedback</comments>
</item>
<item>
 <title>Creating Correlated Workflow Services in WF4 / .NET4 : Part 1</title>
 <link>http://kevinhoffman.sys-con.com/node/1127346</link>
 <description>In the sample I&#039;m going to illustrate in this series of blog posts, I&#039;m going to create a customer service helpdesk application. There will be a single workflow at the core of the application - the customer issue workflow. A customer calls complaining that their widget is completely, horribly broken and the customer service rep starts a new issue. The issue then persists forever while communciation goes back and forth between the customer until finally one of the communication types is a &quot;close ticket&quot; type. This is a really simple workflow, but should be similar enough to things that people do in the &quot;real world&quot; that the sample won&#039;t feel contrived or too &quot;hello world&quot;-ish.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1127346&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 01 Oct 2009 16:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1127346</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1127346#feedback</comments>
</item>
<item>
 <title>How to Build your First Azure-Powered MVC App</title>
 <link>http://kevinhoffman.sys-con.com/node/1124872</link>
 <description>&lt;p&gt;A good friend and colleague of mine has put up a great tutorial that walks you through the process of creating a new &amp;quot;classic&amp;quot; ASP.NET Azure web application and converting it into a cloud-based MVC application. In addition, he shows you how to point your membership, profile, and role providers at Azure cloud storage instead of the default SQL Express. Great read, check it out here:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.caffeinedi.com/2009/09/29/how-to-build-your-first-azure-powered-asp-net-mvc-app/&quot;&gt;http://www.caffeinedi.com/2009/09/29/how-to-build-your-first-azure-powered-asp-net-mvc-app/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1124872&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 29 Sep 2009 14:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1124872</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1124872#feedback</comments>
</item>
<item>
 <title>Configuration Settings in Azure Applications</title>
 <link>http://kevinhoffman.sys-con.com/node/1123631</link>
 <description>&lt;p&gt;One of the double-edged swords of Azure is that it feels so much like building regular web applications. This is a good thing in that you can re-use so much of your existing skills, knowledge, and best practices and they will still apply in the Azure world. However, it is really easy to make assumptions about how things work that turn out to be wrong.&lt;/p&gt;&lt;p&gt;For example, if you look at just about 99% of the Azure samples, blogs, and other reference material, you will see stuff that looks like the code below, sitting right inside &lt;strong&gt;web.config&lt;/strong&gt;:&lt;/p&gt;&lt;pre&gt;&amp;lt;add key=&amp;quot;TableStorageEndpoint&amp;quot; value=&amp;quot;http://foo.table.core.cloudapp.net&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;add key=&amp;quot;QueueStorageEndpoint&amp;quot; value=&amp;quot;http://foo.queue.core.cloudapp.net&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;add key=&amp;quot;BlobStorageEndpoint&amp;quot;&amp;nbsp; value=&amp;quot;http://foo.blog.core.cloudapp.net&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;add key=&amp;quot;AccountName&amp;quot;&amp;nbsp;&amp;nbsp; value=&amp;quot;foo&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;add key=&amp;quot;AccountSharedKey&amp;quot;&amp;nbsp;&amp;nbsp; value=&amp;quot;...lotsa stuff...&amp;quot;/&amp;gt;&lt;/pre&gt;&lt;p&gt;If you were to make assumptions about this, one might assume that you should be putting stuff like this in your web.config file even when you go to staging and production. NO! Stop right there!! This is not how Azure configuration settings are supposed to work!&lt;/p&gt;&lt;p&gt;Equally prevalent in the samples you will find calls to methods like &lt;strong&gt;GetDefaultTableStorageAccountFromConfiguration&lt;/strong&gt;. there is actually a bit of useful logic going on in here that might not be immediately obvious.&lt;/p&gt;&lt;p&gt;This method is going to make attempts at getting configuration information from multiple different locations. It will check the web.config/app.config file, but it will also check your &lt;em&gt;service configuration&lt;/em&gt; file. The most important thing to remember about this file is that it &lt;em&gt;can be edited directly from the Azure portal&lt;/em&gt;. This means that you can deploy your application to stage and then go in and edit the service configuration file to change all the endpoints to your staging endpoints, then activate your app.&lt;/p&gt;&lt;p&gt;The reason this is important is because you never, &lt;em&gt;ever, ever&lt;/em&gt; want to include your Azure key information in your web.config file, especially if you&amp;#39;re posting on forums or sharing your code with other people. This is because if anybody gets your account name and shared key combination, they have full access to your Azure storage account and can basically run amok all over your data.&lt;/p&gt;&lt;p&gt;So, how do you know when you use a &lt;em&gt;service configuration&lt;/em&gt; setting vs. a &lt;em&gt;web.config&lt;/em&gt; setting? Here&amp;#39;s a quick rundown:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;If you need to be able to edit the information after deploying, &lt;em&gt;it must be in service configuration&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt;&lt;/em&gt; in web.config&lt;/li&gt;&lt;li&gt;If the information only changes once per full deploy to production, e.g. it&amp;#39;s version bound not environment bound, you can leave the setting in web.config&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;So, for example, in a typical Azure application, you might store the names of your queues and tables in web.config (because they should rarely change and will remain the same between stage and production), but you&amp;#39;ll put the endpoint information related to your Azure Storage account in the service configuration file. &lt;/p&gt;&lt;p&gt;Hope this helps. The key thing to remember is that Azure service configuration can be a really powerful tool if you know its there... it can also screw you up if you forget its there :)&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1123631&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 29 Sep 2009 11:30:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1123631</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1123631#feedback</comments>
</item>
<item>
 <title>ASP.NET Membership Provider in the Cloud</title>
 <link>http://kevinhoffman.sys-con.com/node/1123632</link>
 <description>&lt;p&gt;Let&amp;#39;s take a look at this pretty common scenario. You&amp;#39;re building an ASP.NET application (MVC or otherwise) and you intend to publish it in the cloud and you&amp;#39;re using Azure Storage (not SQL Azure) for your underlying data store. You&amp;#39;ve already hooked your app up with the sample Azure-based Membership provider that comes with the Azure SDK and everything is running along nicely.&lt;/p&gt;&lt;p&gt;Your application has quite a bit of administrator-only functionality so, after you&amp;#39;ve been using it locally for a while you put in some safeguards to block access to the admin areas unless the user is in the &lt;em&gt;Administrators&lt;/em&gt; role. That&amp;#39;s awesome and ASP.NET and ASP.NET MVC both have some really great code shortcuts for enabling this kind of situation and you can make yourself an administrator pretty darn easily.&lt;/p&gt;&lt;p&gt;So you&amp;#39;re an admin and you deploy your application to staging and you go to run it and you try to log in. &lt;em&gt;Whoops&lt;/em&gt; your account isn&amp;#39;t there. This is because for the last couple of weeks you&amp;#39;ve been running against your local SQL 2008 (or SQL Express) database and you forgot that you did a few tweaks to make yourself an administrator. In the last couple of weeks you removed the code on the site that allows users to self-register since your application is an LOB app with a manually administered user list.&lt;/p&gt;&lt;p&gt;There is a built-in tool that comes with Visual Studio 2008 that allows you to do site administration. In a non-cloud environment, this was a great way to do things because you could simply configure your providers and then click &amp;quot;Project&amp;quot; and then &amp;quot;ASP.NET Configuration&amp;quot; and you would be taken to a Cassini-based website that allows you to add/remove users, manipulate roles, etc. It was great.&lt;/p&gt;&lt;p&gt;The problem is that when you run an Azure application locally, you&amp;#39;re running the &lt;em&gt;Role&lt;/em&gt;, you&amp;#39;re not running the ASP.NET application. This means that when you launch (at least as of last night when I tried this) the ASP.NET configuration site, you&amp;#39;re going to get a pile of errors all stemming from the fact that information contained in your service configuration file wasn&amp;#39;t found and you&amp;#39;ll get other errors because the &lt;em&gt;local fabric&lt;/em&gt; doesn&amp;#39;t get initialized when you don&amp;#39;t start the app through the role.&lt;/p&gt;&lt;p&gt;So what can you do? If you can&amp;#39;t use the admin site&amp;nbsp; then how do you create an admin user that can then create more users? Lots of really talented people have contributed to the MVC community including a fully functional admin site that uses the membership provider to administer users, etc and you can use this if you want. What I&amp;#39;ve been doing, however, to ensure that I&amp;#39;m never left without &lt;em&gt;some&lt;/em&gt; form of administrative access to my sites is by creating a &lt;em&gt;&lt;strong&gt;root account&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;What I do is in the service definition I declare three settings:&amp;nbsp;RootAccountName, RootAccountPassword, AdminRoleName. I then have code in my application startup that will use the Membership API to create this user with the given password and add them to the Admin Role (and create that role if it isn&amp;#39;t created already). This guarantees me that any time I do a fresh deploy or even wipe my storage account that I&amp;#39;ll still be able to login as an administrator to stage or production and I can keep the root account name different between stage and production.&lt;/p&gt;&lt;p&gt;Again, Azure development is awesome and shares a lot of similarities with traditional ASP.NET development but some things (like the built-in site admin tool) don&amp;#39;t work out of the box via the cloud and so we have to keep these things in mind as we build applications for the cloud.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1123632&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 29 Sep 2009 11:30:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1123632</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1123632#feedback</comments>
</item>
<item>
 <title>The Rite of Spring</title>
 <link>http://kevinhoffman.sys-con.com/node/1120634</link>
 <description>The main thing that I get from this picture is a feeling of awe. I mean, it&#039;s Saturn for crissakes... and we&#039;ve got a machine flying around that planet, taking pictures that can be assembled into the massive image in the link and sending those pictures across the solar system back to machines on Earth. Just take a deep breath and stop and think about that for a minute. Today we take virtually all things technological for granted - nobody notices that our phones are using more technology today than the super computers that launched man to the moon 40 years ago. Nobody seems to care that when we were younger, the most awesome kickass gaming rig was a 486 DX2 that ran at 66Mhz. 66Mhz! And that was really just a trick, it&#039;s clock speed was really only 33Mhz.

&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1120634&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 24 Sep 2009 08:29:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1120634</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1120634#feedback</comments>
</item>
<item>
 <title>ViewState is the Froo-It of the Dev-Il</title>
 <link>http://kevinhoffman.sys-con.com/node/1118546</link>
 <description>The other day I was running Microsoft&#039;s malicious software removal tool and, to my shock and horror, it did not remove all of my ASP.NET applications that make use of ViewState. I&#039;m sure it&#039;s just an oversight and Microsoft will be releasing a patch for that soon... if there is one application that could be called malicious, it&#039;s an app that uses ViewState.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1118546&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 23 Sep 2009 22:45:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1118546</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1118546#feedback</comments>
</item>
<item>
 <title>On Testing</title>
 <link>http://kevinhoffman.sys-con.com/node/1114984</link>
 <description>&lt;p&gt;A while ago my mother found a bunch of my grade school (like 3rd - 5th grade era) report cards and progress reports. They pretty universally read like &amp;quot;Kevin is struggling&amp;quot; or &amp;quot;Kevin is having a hard time&amp;quot; and go on and on to describe that I&amp;#39;m not doing well and that my mother really needs to fix it or else I&amp;#39;m going to start failing, etc. I didn&amp;#39;t feel stupid or incapable at the time, I just felt &lt;em&gt;entirely unremarkable&lt;/em&gt;. I didn&amp;#39;t feel as though there was a single thing about me that was any different than any other kid ... except maybe that I didn&amp;#39;t do as well scholastically as my friends. Somehow, despite &amp;quot;needing help&amp;quot; and &amp;quot;struggling&amp;quot;, I was reading at a 12th grade level in 4th grade. I was placed in remedial to average classes until grade 8.&lt;/p&gt;&lt;p&gt;I didn&amp;#39;t know it at the time, of course, but I had (and still have) ADD. I do not have any hyperactivity problems and in fact have sometimes been referred to as a sloth in the past. On subjects that I could obsess over and that interested me, I did exceptionally well (except for testing) and on boring subjects I did exceptionally bad (including testing).&lt;/p&gt;&lt;p&gt;A common thread here is testing. I have never tested well and never will. I hate the experience of being in a test. My stomach churns and I fidget, twitch, itch, and otherwise &lt;em&gt;cannot focus on the test&lt;/em&gt;. I fail tests for easy and hard classes alike and only in recent adult years have I ever been able to pass a test on a boring topic (passed the MCSD exam for SQL Server 2005.. good &lt;em&gt;lord&lt;/em&gt; that test was boring.. I had to take it twice to pass).&lt;/p&gt;&lt;p&gt;While in the middle of a test, there is a single thread running through my mind... it sounds like this &amp;quot;I want to be done. I don&amp;#39;t care if I get all the answers wrong I don&amp;#39;t care if it ruins the rest of my life I don&amp;#39;t care I don&amp;#39;t care &lt;strong&gt;&lt;em&gt;I want to be done!!!&lt;/em&gt;&lt;/strong&gt;&amp;quot;. I remember a mid-term exam for Calculus once while at University - I was maintaining a decent Bish/Cish average. I got to the mid-term, &lt;em&gt;panicked&lt;/em&gt;, and randomly picked all answers on the test and fled the mid-term 15 minutes after the exam began. I failed it and tanked my average. &lt;/p&gt;&lt;p&gt;When someone with my particular type of ADD is confronted with a long-running task that gives them anxiety such as studying for an exam, I have two standard responses: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Obsess about the studying for, preparation for, and acing of, said exam &lt;em&gt;to the exclusion of all else, including daily responsibilities such as acknowledging the presence of one&amp;#39;s family and friends&lt;/em&gt;.&lt;/li&gt;&lt;li&gt;Ignore it. Avoid it. Run like hell and pretend the exam doesn&amp;#39;t exist. When it comes time to take the test, pick random answers and be done with it as soon as humanly possible.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Unfortunately, I have in the past done both #1 &lt;strong&gt;&lt;em&gt;and&lt;/em&gt;&lt;/strong&gt; #2. I&amp;#39;ve spent &lt;em&gt;months&lt;/em&gt; preparing for an exam and then blew it off out of raw, primal &lt;em&gt;fear&lt;/em&gt; when it came time to take the test. That allows me to wallow in self-pity for months after receiving my 0% grade, further increasing my test-related anxiety.&lt;/p&gt;&lt;p&gt;Want to hear how the cycle of self-destruction continued? I decided to start learning Japanese a while back. I felt as though the study of it was floundering (though I was having a &lt;em&gt;crapload of fun) &lt;/em&gt;so I decided maybe if I set a goal, some kind of target, then I&amp;#39;d have more productive studies. What did I set as my goal? Why, the &lt;em&gt;JLPT3 Japanese Language Proficiency Test&lt;/em&gt;, a once-a-&lt;em&gt;year&lt;/em&gt;, international certification. So I did my usual - I turned what was once a fun passtime/hobby into a hyper-obsessed anxiety-ridden downward spiral while preparing for this test.&lt;/p&gt;&lt;p&gt;So I&amp;#39;ve decided to not take the test.. &lt;em&gt;ever&lt;/em&gt;. Regardless of whether or not I think I can pass it, I&amp;#39;ve decided not to take it. Within minutes of making this decision, I felt happier, lighter, and less stressed. The ominous, looming shadow of the upcoming test went away and learning Japanese became instantly fun again.&lt;/p&gt;&lt;p&gt;So what&amp;#39;s the moral of the story? I&amp;#39;m not really sure. A wise friend of mine once passed a quote (perhaps paraphrased) on to me that everyone should live by:&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;&amp;quot;Find out what you don&amp;#39;t like doing, and stop doing it.&amp;quot;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Simple, yet powerful.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1114984&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 21 Sep 2009 13:53:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1114984</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1114984#feedback</comments>
</item>
<item>
 <title>Does Google Translate Suck?</title>
 <link>http://kevinhoffman.sys-con.com/node/1111127</link>
 <description>&lt;p&gt;Before I get into the main part of the blog post, I want to preface this whole thing by saying that I am well aware of the problems of doing language translation by a machine. It&amp;#39;s an inherently difficult problem. &lt;/p&gt;&lt;p&gt;My issue here isn&amp;#39;t so much with Google Translate as it is with the public perception of Google. I&amp;#39;ve read a few reviews of Google Translate and seen some blog posts. The general consensus is that because Google built it, its awesome and flawless. People think that Google is building this massive, soon-to-become-self-aware giant brain in the cloud that is sucking intelligence out of search patterns to be used for some world dominating purpose in the future. &lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1111127&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 17 Sep 2009 08:33:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1111127</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1111127#feedback</comments>
</item>
<item>
 <title>The Difference Between Web Hosting and Cloud Computing</title>
 <link>http://kevinhoffman.sys-con.com/node/1095058</link>
 <description>Yesterday a friend of mine was asking me what I&#039;ve been doing lately in my spare time. When I mentioned that I&#039;d been doing a lot of messing around with Windows Azure, he was naturally curious. After explaining what Azure is, he asked me what the difference was between Windows Azure, a cloud computing environment, and traditional web hosting scenarios.

On a really high level, he&#039;s got a valid point : With Azure you can develop your application offline locally and then when you&#039;re done you can publish it to a remote host. To the casual observer, this looks exactly like what you might do with a web hosting company that provides space on an IIS box and let&#039;s you use ASP.NET and maybe even a little SQL server database.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1095058&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Sat, 12 Sep 2009 17:15:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1095058</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1095058#feedback</comments>
</item>
<item>
 <title>Deploying Azure Hosted Services Should Be as Easy as Deploying a Heroku Application</title>
 <link>http://kevinhoffman.sys-con.com/node/965587</link>
 <description>Recently a friend of mine showed me Heroku, an &quot;instant Ruby platform&quot;. Basically what you can do with Heroku is build your Ruby application and the deployment to the remote Heroku site is not only brainless, painless, and simple, but it can be done entirely from the command line (which means it can be automated even further than it already is). But don&#039;t take my word for it, check out this screencast showing exactly how simple it is to build Ruby applications in the cloud using Heroku.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/965587&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 08 Sep 2009 09:30:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/965587</guid>
 <comments>http://kevinhoffman.sys-con.com/node/965587#feedback</comments>
</item>
<item>
 <title>Silverlight Polling Duplex Channel is NOT a Scalable Solution</title>
 <link>http://kevinhoffman.sys-con.com/node/1022582</link>
 <description>This is great and the programming model for communicating with the Polling Duplex channel is brain-dead simple. It does NOT get any easier to implement push data to a RIA - not in Flash, not in AIR, and certainly not in JavaFX. The problem is that this solution doesn&#039;t scale. On the server side, for each concurrently running Silverlight application (so probably one per concurrent user), there is a full live socket being consumed that will not be relinquished until the client disconnects/closes their browser.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1022582&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 08 Sep 2009 09:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1022582</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1022582#feedback</comments>
</item>
<item>
 <title>Live Framework Developers Get Boned</title>
 <link>http://kevinhoffman.sys-con.com/node/1092793</link>
 <description>When I first read this, I was all &quot;OMFGWTFNoMesh!?!&quot; and exploded in front of my computer. After cleaning the bits of my exploded brain off the keyboard and looking at it again, some of it made sense. They are taking the Live Framework stuff down and theoretically coming up with a better, more in-depth, more unified API for Live. This step is long overdue because for a very, very long time developers have been confused because there is &quot;old live framework&quot; and then &quot;live mesh/live framework&quot; and then there&#039;s Azure and then there&#039;s a bunch of crap that&#039;s been labelled as part of &quot;Live&quot; for which there is no developer API.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1092793&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 08 Sep 2009 09:00:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1092793</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1092793#feedback</comments>
</item>
<item>
 <title>How Win7&#039;s &quot;Boot to VHD&quot; Feature has Changed the Way I Work</title>
 <link>http://kevinhoffman.sys-con.com/node/1086669</link>
 <description>This is normally an adequate situation for me. However, with some things I just don&#039;t want the virtualization overhead or the difference in environment. For example, VS2010&#039;s GUI is written in WPF and that particular GUI hates being virtualized. When put under a virtual machine running Windows 7, VS2010 fails to render things, borders disappear, windows become unusable and the experience is downright awful. On the other hand, when you run VS2010 &quot;bare metal&quot; with no virtualization between it and your video card, everything is beautiful and all works well. &lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1086669&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 08 Sep 2009 08:45:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1086669</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1086669#feedback</comments>
</item>
<item>
 <title>Upgrading the default ASP.NET MVC project with IoC and the Unity Controller Factory</title>
 <link>http://kevinhoffman.sys-con.com/node/965589</link>
 <description>The ASP.NET MVC framework is one of the coolest things to happen to ASP.NET since its creation. One of the things that I love about the MVC framework more than anything else is its flexibility. This flexibility allows it to be configured anyway the developer likes, including replacing the factory that creates controllers.

There are two main things that I wanted to accomplish with the Unity integration. The first was that I wanted my controllers to have the objects on which they depend injected into them in standard DI fashion. Secondly, I wanted the controllers themselves to be resolved through the IoC container rather than being tightly coupled by the routing rules. This would allow me to yank in and out different controller implementations if I need to (I figured this would come in quite handy for TDD and unit testing). &lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/965589&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 22 Jul 2009 11:45:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/965589</guid>
 <comments>http://kevinhoffman.sys-con.com/node/965589#feedback</comments>
</item>
<item>
 <title>Modifying The Default Unit Tests for an ASP.NET MVC Project To Use Moq</title>
 <link>http://kevinhoffman.sys-con.com/node/965590</link>
 <description>When you create a new ASP.NET MVC project, one of the first things that you might notice is that you get an AccountController which takes advantage of the ASP.NET membership provider to allow your site to automatically do forms-based authentication right from the very beginning. This is a very handy feature and definitely helps get you going quickly. 

The issue is that when you look at the unit tests for the AccountController, they are positively littered with manually mocked classes. I realize that this is because you don&#039;t want to make the default project template rely on a third party mocking library so in this blog post, I&#039;m going to show how you can delete all of the manually implemented mocks for the identity, principal, membership service and forms auth service. The secret is using Moq. Moq is a lightweight mocking framework for .NET that was designed specifically for the .NET Framework 3.5 and LINQ. As such, definining mock expectations and mock return values is all done through lambdas in a ridiculously easy to read syntax, as you&#039;ll see below.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/965590&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 22 Jul 2009 11:45:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/965590</guid>
 <comments>http://kevinhoffman.sys-con.com/node/965590#feedback</comments>
</item>
<item>
 <title>Blogs on WCF4, WF4, C#4, Azure, and Goodies Coming Up</title>
 <link>http://kevinhoffman.sys-con.com/node/1009474</link>
 <description>A couple of weeks ago my family and I started packing boxes in preparation for fleeing the great state of New Jersey. We packed everything up, threw as much as we could in the minivan and trekked up to Connecticut where I have taken a new position with a new company as a .NET Architect. As any of you who have moved before know, it&#039;s an incredibly stressful experience and the logistics involved are absolutely ridiculous. It&#039;s a miracle I still know where my car keys, sneakers, and computers are. At one point I was sure I&#039;d left the cat on the roof of the minivan.&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1009474&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 21 Jul 2009 07:30:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1009474</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1009474#feedback</comments>
</item>
<item>
 <title>Fix for Minor Bug in ASP.NET MVC New Project Template</title>
 <link>http://kevinhoffman.sys-con.com/node/965588</link>
 <description>This evening I discovered a minor bug in the new project template for the ASP.NET MVC 1.0 release</description>
 <pubDate>Sun, 03 May 2009 22:48:00 EDT</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/965588</guid>
 <comments>http://kevinhoffman.sys-con.com/node/965588#feedback</comments>
</item>
<item>
 <title>Tour of Oslo: Storing Models in the Repository</title>
 <link>http://kevinhoffman.sys-con.com/node/1112025</link>
 <description>&lt;p&gt;In my&lt;a href=&quot;/oslotour_model2sql.htm&quot; target=&quot;_blank&quot;&gt; last blog post on Oslo&lt;/a&gt; , I walked through a simple scenario where we created an &amp;quot;M&amp;quot; file that contained the models for a fictitious science fiction game. We used this file and IntelliPad to see what the T-SQL might look like if we were to create just the tables defined by the model. In this blog post, I&amp;#39;m going to walk through the process of taking an &amp;quot;M&amp;quot; model, compiling it into an MX image, and finally storing that image in the repository.&lt;/p&gt;&lt;p&gt;If you&amp;#39;re following along, you can grab the &amp;quot;M&amp;quot; file that I created in the previous blog post or you can create your own. The repository is a central storage location for models. Not only does it contain the actual schemas generated by your model image, but it also contains a lot more like security and versioning information. In the interest of keeping this post as small as possible I won&amp;#39;t go into too much detail, but you can find tons of Repository-related videos over on the &lt;a href=&quot;http://msdn.microsoft.com/oslo&quot; target=&quot;_blank&quot;&gt;Oslo Developer Center&lt;/a&gt; . &lt;/p&gt;&lt;p&gt;The first thing we need to do is compile our model. To do that, we&amp;#39;ll use the command-line tool that ships with the CTP called m.exe. This tool can be used to generate regular T-SQL, repository SQL, and of interest to us: a repository image of the model. Sticking with the M file I created last time, I can open up a command prompt, make sure the Oslo SDK &amp;quot;bin&amp;quot; directory is in my path and issue the following command:&lt;/p&gt;&lt;pre&gt;m UlyssesAgenda.m /p:image&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The output is a file named UlyssesAgenda.mx. This is a compiled M file. Now we need to get the compiled M image into the repository. Using this CTP we can accomplish that from the command-line as well using the MX utility:&lt;/p&gt;&lt;pre&gt;mx -i:UlyssesAgenda.mx -d:Repository -s:kev-win7\SQLEXPRESS&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Depending on your configuraiton, you may not need the &amp;quot;-s&amp;quot; command line switch to indicate the server where the Repository database is stored. In my case, I have a full-blown installation of SQL Server 2008 and SQLEXPRESS is not my default instance so I&amp;#39;ve found that every now and then that means I have to modify connection strings or, in this case, pass the server/instance explicitly. &lt;/p&gt;&lt;p&gt;And now we can look at SQL Manager and we see that all of the tables that correspond to our high-level model were created:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://files.blog-city.com/files/J05/88284/p/f/oslotour_models_repository.png&quot; alt=&quot;&quot; width=&quot;323&quot; height=&quot;458&quot; /&gt;&lt;/p&gt;&lt;p&gt;Using the MX command-line tool we can also directly query the repository. I thought it worth showing the output of this because it illustrates one of the more valuable aspects of Oslo - model versioning:&lt;/p&gt;&lt;pre&gt;&amp;gt;mx -l -d:Repository -s:kev-win7\SQLEXPRESS&lt;br /&gt;&lt;br /&gt;Microsoft (R) code name &amp;quot;M&amp;quot; Command-line Utility version 1.0.1308.1&lt;br /&gt;Copyright (C) Microsoft Corporation. All rights reserved.&lt;br /&gt;&lt;br /&gt;Contents of the database&lt;br /&gt;============================================================&lt;br /&gt;&lt;br /&gt;Models.mx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Models.mx;Version=1.0;Locale=neutral&lt;br /&gt;UlyssesAgenda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UlyssesAgenda;Version=1.0;Locale=neutral&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Models.mx is the compiled list of all of the stock models that Microsoft has provided and put into the database as part of the core Oslo offering. What I think is really important to keep track of is that the models themselves are versioned. There are no table versions - the versioning takes place at the model level which is, IMHO, where it should be. Also keep in mind that because at the lowest level we&amp;#39;ve also created a standard SQL schema, you can use any tool you like against this server, including LINQ to SQL or ADO.NET or the Entity Framework.&amp;nbsp; &lt;/p&gt;&lt;p&gt;So now we&amp;#39;ve created a model and put it in the repository. In upcoming blog posts, I&amp;#39;m going to cover some of the other interesting things that you can do with models. &lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://kevinhoffman.sys-con.com/node/1112025&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 31 Dec 1969 19:00:00 EST</pubDate>
 <guid isPermaLink="true">http://kevinhoffman.sys-con.com/node/1112025</guid>
 <comments>http://kevinhoffman.sys-con.com/node/1112025#feedback</comments>
</item>
</channel>
</rss>
