ASP.NET MVC - 使用相同的形式既创建和编辑 [英] ASP.NET MVC - using the same form to both create and edit

查看:145
本文介绍了ASP.NET MVC - 使用相同的形式既创建和编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最新最好的实践方法来创建用于双方创造新的模式和编辑现有的模型形式?

Whats the best practice approach to creating a form that is used to both create new models and edit existing models?

是否有任何教程,人们可以点我的方向是什么?

Are there any tutorials that people can point me in the direction of?

推荐答案

不要使用相同的控制器的操作新建= HTTP PUT。编辑= HTTP POST,所以这是两个不同的东西。这两项行动可以而且应该是相同的控制器上,虽然。

Do not use the same controller action. New = HTTP PUT; edit = HTTP POST, so that's two different things. Both actions can and should be on the same controller, though.

我喜欢使用常见的功能(例如,编辑)的用户控制和包装的想法,在东西具体行动的意见应该只出现在新的或编辑,但不能同时使用。

I like the idea of using a user control for common features (e.g., editors), and wrapping that in action-specific views for stuff which should only appear on new or edit, but not both.

这篇关于ASP.NET MVC - 使用相同的形式既创建和编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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