ASP.NET MVC Tip #50 – Create View Models

Recently, I noticed a nice pattern in the Nerd Dinner application. Nerd Dinner uses strongly typed view model classes to pass data from a controller to a view. This pattern provides you with a convenient way of representing complex view data.

Note: If you haven’t downloaded the Nerd Dinner sample ASP.NET MVC application yet, you really should. It is a really easy to understand sample application that you can use as a great introduction to ASP.NET MVC. You can download it from the http://www.ASP.net/mvc page.

In an ASP.NET MVC application, you pass data from a controller to a view by using view data. There are two ways that you can use view data. First, you can use view data as an untyped dictionary. For example, the controller in Listing 1 returns a collection of products in its Index() action. And, the view in Listing 2 displays the collection by iterating through each item in the collection.

Listing 1 – ControllersProductController.cs

using System.Collections.Generic;
using System.Web.Mvc;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class ProductController : Controller
    {
        //
        // GET: /Product/

        public ActionResult Index()
        {
            // Create list of products
            var products = new List<Product>();
            products.Add(new Product("Laptop computer", 344.78m));
            products.Add(new Product("Bubble gum", 2.00m));
            products.Add(new Product("Toothpaste", 6.99m));

            // Add products to view data
            ViewData["products"] = products;

            // Return view
            return View();
        }

    }
}

Listing 2 – ViewsProductIndex.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="MvcApplication1.Models" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <% foreach (var item in (List<Product>)ViewData["products"])
       { %>


        <li> <%= item.Name %> </li>


    <% } %>

</asp:Content>

The view in Listing 2 is an untyped view. Notice that the products item from view data must be cast to a collection of product items before you can do anything with it.

Instead of using an untyped view, you can use a strongly-typed view. The controller in Listing 3 also returns a collection of products. However, in this case, the collection is assigned to the ViewData.Model property.

Listing 3 – ControllersProduct2Controller.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class Product2Controller : Controller
    {
        //
        // GET: /Product2/

        public ActionResult Index()
        {
            // Create list of products
            var products = new List<Product>();
            products.Add(new Product("Laptop computer", 344.78m));
            products.Add(new Product("Bubble gum", 2.00m));
            products.Add(new Product("Toothpaste", 6.99m));

            // Add products to view data
            ViewData.Model = products;

            // Return view
            return View();
        }

    }
}

Listing 4 – ViewsProduct2Index.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcApplication1.Models.Product>>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <% foreach (var item in Model)
       { %>


        <li> <%= item.Name %> </li>


    <% } %>

</asp:Content>

In Listing 3, the products are assigned to the ViewData.Model property. As an alternative to explicitly assigning data to the ViewData.Model property, you can pass the data to the View() method. In other words, the following two code blocks are equivalent:

// Assign products to Model

ViewData.Model = products;
return View();

// Assign products to Model

return View(products); 

The view in Listing 4 is a typed view. In Listing 4, the Model property represents the collection of products as a collection of products. In other words, you don’t need to cast the view data to a collection of product items before you use the Model property.

Notice the Inherits attribute in the <%@ Page %> directive. The Inherits attribute is used to cast the Model property to a strongly-typed collection of product items. It looks like this:

<%@ Page Inherits=”System.Web.Mvc.ViewPage<IEnumerable<MvcApplication1.Models.Product>>” %>

Kind of a mouthful, but it is clear what it means.

The easiest way to add a typed view into an ASP.NET MVC application is to right-click a controller action and select the menu option Add View. You can specify the type of the view in the Add View dialog (see Figure 1).

Figure 1 – Specifying the type of a view

clip_image002

Notice that, in Figure 1, I specified the view content as a List. Selecting this option results in a strongly-typed view that represents a collection of products. If I had picked Empty instead of List, then I would get a strongly-typed view that represents a single product.

In general, I prefer using typed views instead of untyped views. To my eyes, performing casts within a view looks ugly.

The view data class exposes only one Model property. So what do you do when you need to pass multiple data items from a controller to a view? For example, how do you pass both a collection of products and collection of product categories to a view using a typed view? The answer is to use a view model.

The controller in Listing 5 contains a class named ProductViewModel. This class exposes a property for both the collection of products and the collection of categories. And, the strongly-typed view in Listing 6 displays both the products and product categories.

Listing 5 – ControllersProduct3Controller.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    // View Model Classes

    public class ProductViewModel
    {
        public ProductViewModel(List<Product> products, List<Category> categories)
        {
            this.Products = products;
            this.Categories = categories;
        }

        public List<Product> Products { get; private set; }
        public List<Category> Categories { get; private set; }

    }


    // Controller Class

    public class Product3Controller : Controller
    {

        //
        // GET: /Product3/

        public ActionResult Index()
        {
            // Create list of products
            var products = new List<Product>();
            products.Add(new Product("Laptop computer", 344.78m));
            products.Add(new Product("Bubble gum", 2.00m));
            products.Add(new Product("Toothpaste", 6.99m));

            // Create list of categories
            var categories = new List<Category>();
            categories.Add(new Category("Electronics"));
            categories.Add(new Category("Household"));

            // Return view
            return View( new ProductViewModel(products, categories));
        }

    }
}

Listing 6 –ViewsProduct3Index.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Controllers.ProductViewModel>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <h2>Categories</h2>

    <% foreach (var item in Model.Categories)
       { %>


        <li> <%= item.Name %> </li>


    <% } %>



    <h2>Products</h2>

    <% foreach (var item in Model.Products)
       { %>


        <li> <%= item.Name %> </li>


    <% } %>

</asp:Content>

You can create the view in Listing 6 by selecting ProductViewModel as the data class when adding the view (see Figure 2).

Figure 2 – Adding a strongly-typed view with a ProductViewModel

clip_image004

The pattern that I like here is the pattern of defining the view model in the controller class. The view model is directly related to the controller actions, so it makes sense to define the view model here (in the past, I had created view model classes as separate classes in my Models folder).

Discussion

  1. rickj1 says:

    I’m working through the Nerd Dinner tutorial it is a good hands on beginners like me need hands on examples to bring things into focus
    it is unedited so be sure to download the sample to refer to. MVC Unleashed is not being
    realesed untill july 24 and I’am following it’s development Being a self tought novice new too programing I only have ASP.NET to compare to I thingk MVC is going to be widly used I have two questions about MVC Unleashed
    storing displaying pictures to and from a database and the ability to tie a MVC, Dynamic data and a ASP.NET application wiht some silverlight to pretty it up all together in one app so we can have the best of all four worlds you should devote a chapter to this

  2. Paul Jaime says:

    Very interesting and I am sure I we can use your approach on some of our new development efforts. Thanks!.

    BTW, what do you use to have code formatted with line numbers, like highlight, and color coding? I could use something like this for our programming documentation.

    Thanks,
    -Paul

  3. Casey says:

    Well, all that for “you can keep ViewModel classes in the same .cs file is a little much explanation” …

    Even ReSharper will suggest you sort that smell out, hit Alt-Enter and it will go to it’s own file.

    If you want your ViewModels separate from your Models namespace (though in a well structured MVC application the Models directory would only contain ViewModels) then how about just putting i na ViewModel namespace

    And if you want them together with the Controller, can I suggest a nested class, which truly achieves what you want.

    Putting things into the same CS file is fine for a tutorial app like NerdDinner … but totally inappropriate for an OO language, or any production code.

  4. Hadi Hariri says:

    I concur with Casey. The Models folder inside the MVC app should exclusively be for View Models.

  5. brad says:

    The untyped view dictionary crap is something they should have left off. Its bad practice in any light.

  6. achu says:

    thanks.
    I don’t know it is appropriate place to ask but you might know the answer
    I want to pass an input control value (say textbox1.value) to a controller action method (as a parameter) without a form post (using Ajax.ActionLink). please see the code below.

    I think we cannot put new {name = textbox1.value} in Ajax.ActionLink.


    < % =Ajax.ActionLink("mylink", "linkfunction", new {name = textbox1.value}, new AjaxOptions { UpdateTargetId = "result"})%>

    and controler action is ..
    public string linkfunction(string name)
    {
    return name;
    }

  7. achu says:

    oops html!!

    thanks. I don’t know it is appropriate place to ask but you might know the answer
    I want to pass an input control value (say textbox1.value) to a controller action method (as a parameter) without a form post (using Ajax.ActionLink). please see the code below.

    I think we cannot put new {name = textbox1.value} in Ajax.ActionLink.
    /*
    input type=”text” id=”textbox1″
    Ajax.ActionLink(“mylink”, “linkfunction”, new {name = textbox1.value}, new AjaxOptions { UpdateTargetId = “result”})
    span id=”result”

    and controler action is ..
    public string linkfunction(string name)
    {
    return name;
    }
    */

  8. @Paul — I use the free Syntax Highligher for all of the code listings: http://code.google.com/p/syntaxhighlighter/

    Highly recommended.

  9. Andrei Rinea says:

    I don’t get it why you can place HTML in the comments and work :

    And I agree with Brad regarding the untyped/dictionary-style ViewData… It leads to un-refactorable code.

  10. PK says:

    I use View Data Models (VDM’s) as much as possible. The more something is strongly-typed, the less room for erros (eg. typo’s in magic names/number, etc).

    The difference with what i do and compared to others (i’m finding) is that i’m put the VDM’s in the same folder as the view, because i base the VDM off them.

    for example.
    Views
    Posts
    Index.aspx
    IndexViewData.cs
    Create.aspx
    CreateViewData.cs

    Not every view requires a VDM. But if it did, that’s where i put it. Because of the way i name my views, i can’t put the VDM’s in the root Model folder because of
    a) naming conficts.
    b) it will get tooo busy. (eg. PostIndexViewData.cs, AccountIndexViewData.cs .. eekks.)

    Well, that’s what i’m doing. I doubt if anyone else will like it but it’s worth putting out there.

    -PK-

  11. PK says:

    Ack :( my formatted didn’t work in my previous reply.
    i’ll try again
    Views
    ….Posts
    ……..Index.aspx
    ……..IndexViewData.cs
    (etc)

    -PK-

  12. Farrio says:

    I’m using typed view model in my project as possible as I could. And I think all views should have this. Untyped view data is a good thing to demo but not to a product and I think MS should move it out.

  13. Mark says:

    Hi – sorry for such a basic question – but is putting code within your markup, not a step backwards, rather than ‘full separation’ which was being promoted over the last 7/8 years or so?

    Thanks, Mark

  14. Mr Anonymous says:

    I kind a feeling smart now, cause noticed this pattern weeks ago.

  15. I also find this pattern highly useful, but have still not figure out how to use it for an “Edit” action method. The problem is that POST action method always receives a ViewModel with NULL values, no matter what I enter in the view before submitting.

    I’ve written all the details at stackoverflow.com/…/strongly-typed-viewmodel-…

    Does anyone have some sample code that shows how this pattern would work with a POST action method?

  16. Deepak Chawla says:

    Hi Stephen,
    Your email section of the website does not seem to be working. Hence I’m adding this to the post.

    Regards,
    Deepak Chawla
    —————
    Hi Stephen,
    I have searched and asked quite a few places a simple question which is

    Is there a path where MVC and RIA meat?

    Is the view generation in MVC customisable to actually create a silverlight form..

    Now that would be a proper division of concerns with rich UI.

    I have asked Scott Guthre and also Nikhil Kothari and a few others on their blogs but no answer.

    Thanks.

    Regards,
    Deepak Chawla

  17. boleh says:

    i cannot understand… this is code html or php

  18. David says:

    Thanks so much! Helped me get the typing right that I used for a partial view.

  19. Pravesh says:

    Good tip again from you.. It is very helpful for me in my development. However I’d like to know that when you are coming up with the new suppliment on asp.net MVC framework book..

    Again Thanks for your all tips…

  20. psanders says:

    Unfortunately, nothing new for me.
    Where are the other 49 tips, realy interested in ready them.
    Send me an email. thanks

  21. Areg Sarkissian says:

    Since the models folder
    should be a place to only store view models, with your domain models residing in their own business layer project (referenced by the MVC web site project), why not make the structure of the Models folder the same as the Views folder, where when we add a new controller to our project, a subfolder for that controller is created in the Models folder and also have a shared subfolder in the Models folder for any view models that are shared by multiple controllers. This way view models can have their own home, just like controllers and views do.

  22. Areg Sarkissian says:

    Here is a folder structure example related to my previous comments:

    Views–MyController–Index.aspx
    Views–MyController–Create.aspx
    Views–Shared–Login.ascx

    Models–MyController–IndexViewData.cs
    Models–MyController–CreateViewData.cs
    Models–Shared–LoginViewData.cs

    I guess if any one likes this pattern they can build T4 templates for visual studio to
    create a subfolder when they add a controller, and add a model class when they add an action to the controller.
    Note also since the view model classes are scoped by subfolder namespace there will not be any class name clashing when two different controllers have an action with the same name.

  23. Stephen, thanks for the great article! It took me a while how to make model binding work for POST action methods, but I finally got it.

    In case you are also wondering how to use this technique with POST action methods, you might also want to read my article on this:

    stephenwalther.com/…/…-create-view-models.aspx

  24. Chris says:

    ViewDataModel makes some sense to me for pages that have a model. What about pages that have no model at all?

    IMHO, these ViewData.Model properties might not belong to the model at all.

    Take a product detail page that takes a Product. ViewData.Model is a Product, or that’s how most tutorials express it. What about app level things, like page title or a site name or global email? ViewData.Model.Title implies it’s the models title (Product.Title), not the Page Title or any other title.

    I think ViewDataModel blurs the spirit of what what ViewData,Model is, or appeared to be: the object for the main focus of the action. A Product for a detail page, a list of Products for a products page, etc. Other data should be at the ViewData level, not at the ViewData.Model level.

    What I tend towards is an AppData : ViewDataDictionary class and set it to the ViewData property in the controller constructors.

    This means I have to also set the page inherits correctly.

    I’ve also seen people bypass both methods and just user helpers in the view.

  25. Chris says:

    Or, in other words…

    Some say to never use the name/value key/pairs directly at all. So, if we’re going to stuff everything into a ViewDataModel, as ViewData.Model.EveryOtherProperty, it seems we should just ditch the ViewData.Model property altogether and go with custom ViewData classes in some future version.

    This particular topic seems like a sharp corner to me in 1.0. Of course, if we have Extension Properties to add to ViewDataDictonary, all would be solved as well.

  26. Chris says:

    I'[ll stop commenting on myself. I promise. A better example:

    ViewData.Model.PageSize
    ViewData.Model.PageNumber

    this would be a better goal to my eyes:

    ViewData.PageSize
    ViewData.PageNumber

  27. gabotmetal says:

    this article make me headache emm thank u for being this good info :)

  28. Chris says:

    I went back and took a look at the Preview 3 time frame. Now I understand my confusion.

    The old ViewData WAS the Model before there was a model. It could be subclassed and it was passed directly to RenderView.

  29. J Stroud says:

    Stupid question, probably, but whenever I try and add a strongly typed view in the “Add View” dialog, the “Add” button gets disabled. What’s more, my model classes aren’t showing up in the dropdown.

    Any ideas?

  30. Anonymous says:

    Yea, I do not get why MS (not necessarily this post) continually push examples or documentation using poor practices. Examples: Datasets, untyped dictionaries, you name it. I don’t care if it’s for demo purposes or not. What you preach says a lot about your products and work ethics. I don’t think DataSets, Entity framework, or things like this should ever have been invented by Microsoft. People need to learn how to code! Pushing bad practices by pushing poor packaged canned objects that go against separation of conerns etc. is just very poor overall as a company by Microsoft.

  31. Anonymous says:

    JStroud,

    Why is that a “stupid question”? I get tired of the development community expecting every developer to just “figure it out and do not ask questions”. Most developers do try to figure things out. So no need to say “stupid question”, just fire away. It’s a simple question but of course most things even architect leads have problems with are those “simple things”. We as developers should not have to feel that we have to preface questions with “sorry” or “this is stupid but”. Fuck the other developers and just ask.

  32. @Stroud — That is not a stupid question — I got confused about it myself. You need to do a build of your project (select Debug, Build Solution) before opening the Add View dialog. Otherwise, the data classes won’t appear in the dropdown list. The Add button is disabled until you pick a data class.

    Hope that helps!

  33. J Stroud says:

    Stephen.Walther:
    Well, that’s intuitive! Thanks for the input.

    It’s one of those things that NO tutorial mentions.

    There are no stupid questions, of course. Only stupid answers. ;)

    Anon:
    “We as developers should not have to feel that we have to preface questions with “sorry” or “this is stupid but”. Fuck the other developers and just ask. “

    Brilliant. Just brilliant. Considering that 90% of our communications workload is asking questions, you are absolutely spot on.

  34. Imho says:

    Just want to test javascript here :)

  35. rickj1 says:

    Speaking of questions I have one that I can’t seem to find an answer to I’ve asked on a number of fourms I’m doing Nerd Dinner for the secound time I’m up to chapter 9 in your new book watched all the videos and I’m going to work on your contact manager I’m am trying to put together a MVC site of my own for practice
    standard web design membership, profile with picture in database picture tied to Guid UserId tow things need to be done return all the profiler for browsing and return single user based on logged on user for editing Is there a good example, artical are you going to include this in your book maybe write a blog post showing how to do it I’ve tried every sujestion every way I can think of and I cant get it to come out

  36. Mario says:

    Nice, I dont see no other way to do it

  37. sheraz says:

    i have a question about the re usability of viewusercontrols .As we know that we can make a viewusercontrol and place all the view rendering info in it.but still the controller of page is responsible to get the data.So, this means that if i use this control on different pages than i will have to write the Controller code in every function that i create for that particular page.
    please advise that if there is any other way to increase the viewusercontrol reusability.

  38. I don’t think DataSets, Entity framework, or things like this should ever have been invented by Microsoft. People need to learn how to code! Pushing bad practices by pushing poor packaged canned objects that go against separation of conerns etc. is just very poor overall as a company by Microsoft.

  39. bando says:

    Hi,
    I’m not sure if this is the place to ask questions (and sorry if it isn’t)

    I’m trying to use View Model but on my View page somehow “Model” doesn’t get recognized.

    This is the error I get. “The name ‘Model’ does not exist in the current context.”

    I verified that viewpage has the correct heading.
    < %@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage” %>

    Can someone help me please??
    Thanks, Bando

  40. Thanks for the great article! It took me a while how to make model binding work for POST action methods, but I finally got it.

  41. Anonymous says:

    So you’re placing the ViewModel class in the same namespace as your controller rather than creating a separate class for the ViewModel. Is that just preference (organization of structure to keep similar things in the same place physically) or what? I would lean to creating an entire .cs for each ViewModel class as it could grow a bit. Ideally you probably shouldn’t have a super long ViewModel class but I don’t know, throwing that into your controller might cloud up things? Maybe I’m being too picky.

    Opinions anyone?

  42. Really very nice post. This post will help me a lot. Thanks for sharing.

  43. Great Post. I too think strongly typing is the way to go… however for this simple example with a select list or two, I don’t necessarily see the benefit of writing more code to handle this.

  44. Nice Post! Thanks for giving very useful information.

  45. Great Post! Really very interesting one. I enjoyed a lot.

  46. I wasn’t aware of Nerd Dinner application. Thanks for putting the source here.

  47. Hood Figure says:

    Thanks for the useful ASP.Net tips for creating view models. It really helps me to understand more deeply.

  48. seo india says:

    Very interesting.

  49. seo says:

    Really very nice post.

  50. Absolutely Brilliant.

  51. seotips says:

    Great Post! Really very interesting one.

  52. linkexchnage says:

    Thanks for putting the source here.

  53. seo-tips says:

    Thanks for the useful ASP.Net tips.

  54. sem-tips says:

    Great, I enjoyed a lot.

  55. seo-tips says:

    Thanks for giving very useful information.

  56. bookmarking says:

    Nice Post! Thanks.

  57. blog-seo says:

    strongly typing is the way to go.

  58. key-phrases says:

    Very nice post.

  59. website says:

    This post will help me a lot.

  60. semantics says:

    Thanks for the great article.

  61. designe says:

    Thanks for the useful info. It’s so interesting.

  62. adsense says:

    thank u for being this good info.

  63. seo-sem-tips says:

    Great Very nice post.

  64. seo-benefits says:

    Thanks for the useful info.

  65. Thank you for useful ASP.Net tips.

  66. seo says:

    Thanks, This post will help me a lot.

  67. Svevarn says:

    Very nice article.

    One thing I wonder about…. how to add paging so it still looks pretty as listing 5? Tried to apply “a-la Nerddinner” but doesnt quite work. Always the “excpected model type blah blah”.

  68. Bob says:

    OK, I see how you get two different tables on same view but i’m having trouble getting two related tables in a view. How do I just get the product rows to show with the product category for each product in the appropriate row? Sorry if I’m missing something easy.

  69. Bob says:

    I think I’ve answered my question:

    1. Added new class containing product properties and category name.
    2. Added new method to repository that gathers product properties and category name via linq join.
    3. Changed controller to use the new method.
    4. Changed view to use new class.

    similar method at: stackoverflow.com/…/how-to-create-a-strongly-…

    Regards, Bob

  70. will says:

    great script, thanks

  71. uspeh says:

    thanks for code

  72. Great article and a nicely written version of the video tutorial. I do have just one thing to say and that is, I love the MVC framework although I must admit, it does feel like a step away from some of the key components within the .NET framework. I understand why, but for example, will server controls become obsolete?
    Thanks,
    James

  73. mei this is given in attachment. I understand that very well. Thanks.

  74. Joel says:

    What an astounding amount of spam comments on this post. Clever of them to use the URL field and post generic “way to go” messages as the actual comment, I guess. Something tells me the CAPTCHA on this site is a bit broken, though.

  75. What an astounding amount of spam comments on this post. Clever of them to use the URL field and post generic “way to go” messages as the actual comment, I guess. Something tells me the CAPTCHA on this site is a bit broken, though.

  76. tutu says:

    M&A is wonderful.
    携帯電話レンタル is wonderful.
    屋形船 is wonderful.
    店舗デザイン is wonderful.
    整体学校 is wonderful.
    お見合いパーティー is wonderful.
    債務整理 is wonderful.
    演劇 is wonderful.
    新宿 整体 is wonderful.
    会社設立 is wonderful.
    マカ is wonderful.
    格安航空券 国内 is wonderful.
    ブライダルエステ is wonderful.
    募金 is wonderful.
    オーディション is wonderful.
    広島 不動産 is wonderful.
    バイク便 is wonderful.
    ボイストレーニング is wonderful.
    過払い is wonderful.
    バラ is wonderful.
    キレーション is wonderful.
    先物取引 is wonderful.
    洗面化粧台 is wonderful.
    税理士 東京 is wonderful.
    カップリングパーティー is wonderful.
    ウェディングドレス is wonderful.
    結婚式 青山 is wonderful.
    看護師 募集 is wonderful.
    トイレつまり is wonderful.
    商標弁理士 is wonderful.
    電話代行 東京 is wonderful.
    ハーレー is wonderful.
    貸事務所 is wonderful.
    会社設立 is wonderful.
    賃貸オフィス is wonderful.
    債務整理 東京 is wonderful.
    会社設立 横浜市 is wonderful.
    水虫 治療 is wonderful.
    温泉 旅館 is wonderful.
    川口市 一戸建て is wonderful.
    川口市 一戸建て is wonderful.
    エアコン 修理 is wonderful.
    ガーデン エクステリア is wonderful.
    結婚式2次会 幹事代行 is wonderful.
    相続税対策 is wonderful.
    インプラント 歯科 is wonderful.
    ゴルフ会員権 is wonderful.
    埼玉県 一戸建て is wonderful.
    ベビーマッサージ is wonderful.
    相続 遺言
    中古医療器械

  77. Pretty good post. I just found your site and wanted to say that I have really enjoyed browsing your posts.In any case I’ll be subscribing to your blog and I hope you post again soon!i like this

  78. Trin says:

    Steve, Your explanation of View Models is very good. I am using .NET 3.51, and I am trying an example with 3 tables with columns as follows

    CAR – (carid, ownerid, carvalue)
    OWNER – (ownerid, owner_name)
    CAR TYPE – (cartypeid, cartype_desc)

    1. In a view, I need to display the list of cars AND car type desc for an Owner

    2. How do I update Car ?

  79. sikis izle says:

    it seems it is okey thanks

  80. Thanks for the great article!

  81. Sharon says:

    Great article and a nicely written version of the video tutorial. I do have just one thing to say and that is, I love the MVC framework although I must admit, it does feel like a step away from some of the key components within the .NET framework.
    discount codes | promotional codes are more important than ever to people trying to save money on their shopping online.Such as Asda Discount Codes | Tesco Voucher Codes | Argos Discount Codes | Comet Discount Codes all the UK retailers seem to be gearing up to offer us big discounts, offers and incentives to get on and shop. Diapers Coupon Codes|Newegg promo codes and Musicians Friend Coupon Codes and Kohls Coupon Codes and Sears Coupon Codes A minute or two online can save you big money.

  82. games says:

    Great post! Helped me a lot.

  83. DSD-SICO says:

    I really like the idea of having the notion of ViewModels and Domain models. However, where would you put your validation code? Simply in the ViewModel, or just in the Domain Model, or in both places? Does anyone have recomendations on that?

  84. Thanks for posting this, it is exactly the explaination I have been looking for, and it certainly helps being able to see the screenshots as you are going through it, good stuff!

  85. common says:

    The spill of coal fly ash from a holding pond in Tennessee on Dec. 22 dumped 1.1 billion gallons of sludge, according to the Knoxville News Sentinel. Such sludge contains coal combustion waste products, among them arsenic, lead, barium, thallium and other substances that can cause cancer, liver damage, neurologic disorders, and other serious ailments. Covering 300 acres, the spill was 48 times larger than the Exxon Valdez oil spill. (Cheap Logo Designstationery designLogo Design Services )

  86. matt says:

    The spill of coal fly ash from a holding pond in Tennessee.
    Term Paper Help| Custom Term Paper| Buy Term Paper| Online Term Paper|

  87. Kristen Stewart says:

    I understand that very well. Thanks.

  88. chris says:

    I understand that very well. Thanks.
    kamagra tabletsBuy kamagraonline kamagra

  89. Thanks for this, it is a great tip to use, I shall try it today.

  90. 32 2 It’s lucky to know this, if it is really true. Companies tend not to realize when they create security holes from day-to-day operation.

  91. sohbet says:

    http://www.tiryakichat.com” title=”chat, odalari”target=”_blank”>chat
    http://www.tiryakichat.com” title=”sohbet, odalari”target=”_blank”>sohbet
    http://www.tiryakichat.com” title=”yonja, sohbett”target=”_blank”>yonja
    http://www.tiryakichat.com” title=”muhabbet, sohbett”target=”_blank”>muhabbet
    http://www.tiryakichat.com” title=”kızlarla sohbet”target=”_blank”>kızlarla sohbet
    sohbet
    kizlarla sohbet
    http://www.sohbet58.net” title=”sohbet, yonja”target=”_blank”>sohbet odaları
    bedava sohbet
    sohbet siteleri
    chat siteleri
    forum
    forum siteleri
    yonja
    sohbet
    sohbet odalari
    sivas sohbet
    sivas chat

  92. sohbet says:

    thanks

    http://www.tiryakichat.com” title=”chat, odalari”target=”_blank”>chat
    http://www.tiryakichat.com” title=”sohbet, odalari”target=”_blank”>sohbet
    http://www.tiryakichat.com” title=”yonja, sohbett”target=”_blank”>yonja
    http://www.tiryakichat.com” title=”muhabbet, sohbett”target=”_blank”>muhabbet
    http://www.tiryakichat.com” title=”kızlarla sohbet”target=”_blank”>kızlarla sohbet
    sohbet
    kizlarla sohbet
    http://www.sohbet58.net” title=”sohbet, yonja”target=”_blank”>sohbet odaları
    bedava sohbet
    sohbet siteleri
    chat siteleri
    forum
    forum siteleri
    yonja
    sohbet
    sohbet odalari
    sivas sohbet
    sivas chat

  93. I really like the idea of having the notion of ViewModels and Domain models. However, where would you put your validation code? Simply in the ViewModel, or just in the Domain Model, or in both places? Does anyone have recomendations on that?