Model binding problem when multiple forms on the same page
This is more of an mvc question.
I have 2 partials on a page. Both have forms which post to different controllers. The models are different.
Both models have a property called Name, which renders as a textbox.
After a post of one form, the page renders, but both forms now have the value in their respective textboxes. Something is happening to model bind both forms to the posted value.
i'm not sure if this is best practise but done it before by setting a HtmlFieldPrefix on the TemplateInfo which you can pass in your ViewDataDictionary... i'll see if i can digg up that piece of code again.
Model binding problem when multiple forms on the same page
This is more of an mvc question.
I have 2 partials on a page. Both have forms which post to different controllers. The models are different.
Both models have a property called Name, which renders as a textbox.
After a post of one form, the page renders, but both forms now have the value in their respective textboxes. Something is happening to model bind both forms to the posted value.
i'm not sure if this is best practise but done it before by setting a HtmlFieldPrefix on the TemplateInfo which you can pass in your ViewDataDictionary... i'll see if i can digg up that piece of code again.
Cheers,
/Dirk
Can't seem to find it atm, but here's a sample i've found on the www http://code.lawrab.com/2012/05/using-bind-prefix-in-aspnet-mvc.html
Cheers,
/Dirk
Nice! That looks like exactly what i need!
Thanks!
I realize this is an old thread, but what's the next step? I did what was shown in the link, but I can't get the forms to process.
is working on a reply...