采用基本相同视图编辑和查看 [英] Using almost same view for editing and viewing

查看:94
本文介绍了采用基本相同视图编辑和查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的问题是关于同时处理编辑和同一视图中查看文档数据。基本上,我有可以查看文档数据的视图。它有必要的字段,可以显示用户的文本信息。我怎样才能,伙计们,编辑采用这一说法这个文件?
所以看起来我需要通过一些标志,指示编辑或查看模式和显示文本框编辑或只是文字。
任何技术方法来实现这一目标?你能,伙计们,建议我的东西吗?所有博客文章,文章,手册将是非常美联社preciated。
在此先感谢家伙!
P.S:它是ASP .NET MVC3应用程序(使用的Razor视图引擎)。

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).

推荐答案

我通常做到这一点使用两个歧动作(详细信息和编辑)。你会使用AcceptVerbs装点你的行动。 POST与GET在这种情况下。你可以创建一个由两个动作返回一个单独的局部视图。其行为(只读/编辑)将返回该视图的操作决定。

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

重用视图(部分图)

这篇关于采用基本相同视图编辑和查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆