+3  A: 

I would suggest that you create a ViewModel and have your View be totally unaware of the fact that data is or is not coming prepopulated from the DB at all.

If you are prepopulating data.. then fill your ViewModel with the necessary data (and disable the inputs that are coming prepopulated)

If you are starting from scratch.. then fill your ViewModel with empty/default data

Either way, all your view does is display the form, and populate default data on the various textboxes and other inputs based upon the passed in ViewModel.

Jon Erickson
+2  A: 

In your View Model:

public class RegistrationViewModel
{
    public bool Invited;

    /*
     * Fields for prepopulating inputs
     */
}

In your View:

<%= Html.TextBox("email", null, Model.Invited ? new { @readonly = "readonly"} : null) %>

or

<%= Html.TextBox("email", null, Model.Invited ? new { @disabled = "disabled"} : null) %>
eu-ge-ne
Is there any performance impact on using Html.Textbox instead of directly writing <input ... etc. ?
Alex
Absolutely NO. Use Html.Textbox where it is possible
eu-ge-ne
What are the advantages of Html.* over the direct tag equivalent? Just trying to understand the reasoning. Thank you :)
Alex
Html.Textbox("value" ...) populates its value from ViewData or ModelState (if there is no "value" in the ViewData). Also it is possible to define "default" value (if both ViewData and ModelState are empty). It also minimizes the possibility of rendering incorrect markup.
eu-ge-ne
How could I have my POST /register return the ViewModel? (e.g. Register(RegistrationViewModel registrationVM) then? So I don't have to use FormCollection...
Alex
On POST you must use Model, not View Model (Register(UserModel user)). You Model will be populated by DefaultModelBinder or your custom ModelBinder.
eu-ge-ne
A couple of articles, you may be interested: (1) http://stephenwalther.com/blog/archive/2009/02/27/chapter-5-understanding-models.aspx (2) http://stephenwalther.com/blog/archive/2009/04/13/asp.net-mvc-tip-50-ndash-create-view-models.aspx
eu-ge-ne