If I am passing an XElement or XDocument to my ASP.NET MVC view, what's the best (read: easiest) way to repopulate my XML with the values returned from the edit form开发者_开发技巧 on submit?
Thanks,
Matt.
Typically you want a strongly typed model coming into an action, but if you have a good reason to take in XML, then here is the approach I would take:
Create a custom ModelBinder that will do the work for you. In the ModelBinder you can loop through the form and get everything that was submitted and create your XElement. In the global.asax you can specify that you want to use that ModelBinder whenever you have a type of XElement or XDocument.
精彩评论