开发者

Using almost same view for editing and viewing

So my question is about handling both editing and viewing document data in same view. Basically, I have a view t开发者_C百科hat 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).


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜