code_junkie

ASP.NET MVC - using the same form to both create and edit

Nov 13th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>" MasterPageFile="~/Views/Shared/Site.Master" %>
  2. <asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
  3. Host a Nerd Dinner
  4. </asp:Content>
  5. <asp:Content ID="Create" ContentPlaceHolderID="MainContent" runat="server">
  6. <h2>Host a Dinner</h2>
  7. <% Html.RenderPartial("DinnerForm"); %>
  8. </asp:Content>
  9.  
  10. <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>"
  11. MasterPageFile="~/Views/Shared/Site.Master" %>
  12. <asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
  13. Edit: <%:Model.Title %>
  14. </asp:Content>
  15. <asp:Content ID="Edit" ContentPlaceHolderID="MainContent" runat="server">
  16. <h2>Edit Dinner</h2>
  17. <% Html.RenderPartial("DinnerForm"); %>
  18. </asp:Content>
  19.  
  20. <%@ Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.Dinner>" %>
  21. <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
  22. <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
  23. <script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
  24. <% Html.EnableClientValidation(); %>
  25. <%: Html.ValidationSummary("Please correct the errors and try again.") %>
  26. <% using (Html.BeginForm())
  27. { %>
  28. <fieldset>
  29. <div id="dinnerDiv">
  30. <%:Html.EditorForModel() %>
  31. <p>
  32. <input type="submit" value="Save" />
  33. </p>
  34. </div>
  35. <div id="mapDiv">
  36. <%: Html.EditorFor(m => m.Location) %>
  37. </div>
  38. </fieldset>
  39. <% } %>
Add Comment
Please, Sign In to add comment