Monday, 15 August 2011

asp.net mvc - Html.BeginForm inside of Html.BeginForm MVC3 -



asp.net mvc - Html.BeginForm inside of Html.BeginForm MVC3 -

i have main view renders 2 partial views. main view encompasses both of partial views within form. each of partial views contain forms. 3 views share same viewmodel. want encapsulate info views main view, , run specific controller action results partial views.

i want know if possible. when debugging see content posts httppost of main views form. have submit buttons each of forms accordingly. sorry code post, coming out split up.

main view:

@using (html.beginform("main", "registration", formmethod.post, new { @class="mainform" })) { <form> <fieldset> <div id ="option1" class="conglomerate"> @html.partial("_getbusiness") </div> <div id ="option2" class="dealership"> @html.partial("_getlocation") </div> <button type="submit" value="create" class="buttonblue" id=""> <span>create new dealer</span> </button> </fieldset> </form>

partial 1

@using (html.beginform("createbusiness", "business", formmethod.post, new { @class="buisinessform" })) { <form> <div class="editor-field"> @html.dropdownlistfor(m =>m.businessid, new selectlist(model.businesses, "businessid", "businessname"), "") </div> <label>your company not listed? register yours below:</label> <div class="editor-label"> @html.labelfor(model => model.businessname) </div> <div class="editor-field"> @html.editorfor(model => model.businessname) @html.validationmessagefor(model => model.businessname) </div> <button type="button" value="" class="buttonblue"id="testsubmit"> <span>add dealer</span> </button> <div class ="confirm"> <button type="submit" value="create" class="buttonblue" id=""> <span>click here confirm dealer addition</span> </button> </div> </form> }

as dave mentions, not valid html nest forms. it's not html5, version of html.

it might work in browsers, in circumstances, never valid. , can never depend on happen if seem work. best course of study of action utilize multiple non-nested forms on page.

can explain why think need nested forms?

html asp.net-mvc asp.net-mvc-3 razor

No comments:

Post a Comment