Self-AJAX-updating partial-view/controller in ASP.Net MVC and the duplicating div

后端 未结 6 683
生来不讨喜
生来不讨喜 2021-01-04 12:04

I have a partial view in MVC that goes something like:

...

Inside that div there\'s a form tha

6条回答
  •  庸人自扰
    2021-01-04 12:44

    I had this same problem in Asp.Net MVC 5.

    I did not want the PartialView to have some knowledge about what div it might be contained within, so I did not accept that work around.

    Then, I noticed the other answers referring to ReplaceWith and found the simple solution:

    InsertionMode = InsertionMode.ReplaceWith
    

    Now, the mvc partial view can completely replace itself with the ajax helpers without having any dependencies on names outside itself.

提交回复
热议问题