Whats the best practice approach to creating a form that is used to both create new models and edit existing models?
Are there any tutorials that people can point me in
NerdDinner will really show the way.
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Views/Shared/Site.Master" %>
Host a Nerd Dinner
Host a Dinner
<% Html.RenderPartial("DinnerForm"); %>
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage"
MasterPageFile="~/Views/Shared/Site.Master" %>
Edit: <%:Model.Title %>
Edit Dinner
<% Html.RenderPartial("DinnerForm"); %>
<%@ Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.EnableClientValidation(); %>
<%: Html.ValidationSummary("Please correct the errors and try again.") %>
<% using (Html.BeginForm())
{ %>
<% } %>
Take into account that this form is using Html.EditorForModel(), which is an innovative method for generating all the fields at once, and you have to study its disadvantages before using it. But you can easily take the rest of the example to separate your common form from the create and edit views.
Finally you can view the controller code here if you are interested.