Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
Email<input type="text" id="email" /><br />
Re-enter Email<input type="text" id="confirm-email" />

I'm thinking that I want a model so that I can have this partial page strongly typed. But what a lame model....

It would look like this, and if this is a good Idea, what should I name this model?

public class ConfirmEmailModel?????
    [Display(Name = "Email",ResourceType=typeof(mvc3test.Resources.Common))]
    public string Email{ get; set; }

    [Display(Name = "Confirm Email")]
    [Compare("Email", ErrorMessage = "no match.")]
    public string ConfirmEmail{ get; set; }
share|improve this question

call it a "view model" as its not really a model, its just a model for the view you are showing.

ConfirmEmailViewModel :)

share|improve this answer

I don't know ASP.NET, but isn't this the job of a view helper? Or an "HTML Helper" as they put it.

An HTML Helper is just a method that returns a string. The string can represent any type of content that you want. For example, you can use HTML Helpers to render standard HTML tags like HTML and tags. You also can use HTML Helpers to render more complex content such as a tab strip or an HTML table of database data.

I say don't create a "view model," instead create a view helper.

That is straight from:

share|improve this answer

No I don't believe it is overkill. I've felt the same about view models for simple things in the past but it adds bits which are helpful, such as strongly typing and validation.

As Keith, I'd also call it ConfirmEmailViewModel.

share|improve this answer

I like to take an MVVM style approach to MVC, for example, I use:

public class Person { }

as my domain model, and

public class PersonViewModel { }

as my view model. The view model is expressly used with the Controller and View. I also tend to use a mapping framework quite a lot, so I might mock up something like

public PersonController(IViewModelService<PersonViewModel> viewModelService)
    _viewModelService = viewModelService;

public ViewResult Edit(int id) 
    PersonViewModel model = _viewModelService.Get(id);
    return View(model);

public ViewResult Edit(PersonViewModel model)
    if (ModelState.Valid)

    return View(model);

where the IViewModelService<PersonViewModel> service is responsible for mapping my view model back to my domain model Person.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.