Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 12, 2013 @ 02:00
    Anthony Dang
    0

    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. 

    Any mvc guru's? 
  • Dirk De Grave 4539 posts 6012 karma points MVP 3x admin c-trib
    Apr 12, 2013 @ 09:04
    Dirk De Grave
    0

    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

  • Dirk De Grave 4539 posts 6012 karma points MVP 3x admin c-trib
    Apr 12, 2013 @ 09:06
    Dirk De Grave
    1

    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

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 12, 2013 @ 11:29
    Anthony Dang
    0

    Nice! That looks like exactly what i need!

    Thanks!

     

  • lonehorseend 24 posts 71 karma points
    Mar 21, 2015 @ 06:54
    lonehorseend
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft