I am trying to build a generic form submission system using ASP.NET MVC. I'd like to make it as easy as possible to create forms with a form view and a "success" view. Using the WebForms method, this was easy and could be accomplished with templates or multiviews. With MVC, I'm a bit stuck.
Here's what I'd like to emulate:
<% if (formNotSubmitted) { %>
<% Html.BeginForm(...); %>
<%= Html.TextBox("FirstName") %>
<%= Html.TextBox("LastName") %>
<input id='submit' type='submit' value='Submit' />
<%= Html.ValidationSummary %>
<% Html.EndForm(); %>
<% } else { %>
<p>Thank you!</p>
<p><img src='thanks.jpg' /></p>
<p>Other items here maybe.</p>
<% } %>
Ideally, I'd like to use Ajax, but also have it work with a straight POST. I'd also like to wrap this somehow to avoid the "if..else" code. What makes this harder than a typical ASP.NET MVC Ajax form is that the controller won't know what the success message/content is supposed to be. Most demos I've seen have the controller send back a message, but I need that code in the view.
Any guidance is appreciated.