如何制作“自定义创建表单”在 asp mvc 2 中?
可能我的问题会有点令人困惑,我正在使用 asp mvc 2 构建一个简单的预订系统(我是初学者),我已经使用它的控制器生成了 CRUD 视图。当我转到 ~/bookings/create 时,会出现自动生成的创建表单。但它与文本字段一起出现,我正在努力通过一些下拉列表来更改它们。问题是,如何使用所有下拉列表和文本字段中的选定值保存表单?
谢谢你!如果这是一个奇怪的问题,我很抱歉,这是我第一次使用 Stack Overflow。
May be my question is going to be a little confusing, I'm building a simple booking system with asp mvc 2 (I'm a beginner) I've generated the CRUD views with it's controller. When I go to ~/bookings/create appears the autogenerated create form. But it appears with textfields, well I'm working on it changing them by some dropdown lists. The question is here, how do I save the form with the selected values in all the dropdowns and the textfields?
Thank you! And sorry if It's kind of strange question, It's my first time on Stack Overflow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要另一个带有 [HttpPost] 属性的操作方法,它将接受您呈现为表单的相同模型对象。
因此,假设以下是您用来创建表单的操作方法:
您将需要创建另一个方法,如下所示:
You will need another action method adorned with [HttpPost] attribute and it will accept the same model object that you rendered as your form.
So suppose the following was your action method that you used to create your form:
You will need to create another method like the following: