So my question is about handling both editing and viewing document data in same view. Basically, I have a view that can view document data. It has necessary fields and can show text information for user. How can I, guys, edit this document using this one view? So seems like I need to pass some flag that indicates "editing" or "viewing" mode and show edit textboxes or just text. Any techniques, methods to achieve this? Could you, guys, advice me something? Any blog posts, articles, manuals will be very appreciated. Thanks in advance guys! P.S.: it is ASP .NET MVC3 application (with Razor view engine).
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I usually accomplish this using two differant actions (details and edit). You would decorate your actions using AcceptVerbs. POST vs. GET in this case. You can create a single 'partial view' that is returned by both actions. Its behavior (readonly / editable) will be dictated by the action that returns the view.
There is a very straight forward tutorial covering just this here:
CRUD
Reusing Views (Partial View)
标签:
asp.net-mvc-3