MVC显示和编辑相同的视图 [英] MVC same view for both display and edit

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

问题描述

我可以使用局部视图来编辑弹出对话框中的人员详细信息,但是他们还希望具有显示"模式,该模式禁用了视图中所有可编辑的文本框,下拉列表框和链接,有人可以告诉我多么容易我可以做到这一点(不使用javascript)

I have the a partial view use to edit the person details in the popup dialog, but they also want to have "display" mode, which disabled all editable textbox, dropdownlistbox and links in the view, can someone tell me how easy I can achieve this (not using javascript)

推荐答案

您可以在条件视图中使用相同的视图来禁用编辑器,但是这样很快就会变得混乱.更好的方法是为可编辑视图使用单独的cshtml文件,并在对View或RenderPartial的调用中指定适当的视图名称.

You can use the same view with conditionals to disable the editor, but that gets messy really quickly. A better approach is to have a seperate cshtml file for the editable view and specify the appropriate view name in the call to View or RenderPartial.

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

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