weixin_33724046
weixin_33724046
采纳率0%
2019-11-24 17:29 阅读 16

.NET MVC模式表格提交

Just a general question regarding submitting forms within a modal and the associated Action.

I have an existing standard form that scaffolding creates for you which uses the "Cases/CreateCase" action. This action would save the form and has a standard Redirect To Action to return Index.cshtml

I want to allow the user to do a shortened "Quick Case" version of this case form from the home page.

I have updated the Home/Index.cshtml to include a button which will open a modal (modal id = "createCaseModalForm") which contains a form for "Cases/CreateQuickCase" action. This is currently an ActionResult.

This uses similar logic to the previous "Cases/CreateCase" action, but this time rather than have a re-direct action for submission I simply want for the data to be saved and the modal to close. ID of the form is "#createQuickCaseForm"

Do I need ajax for this modal submission?

What should the Controller action return, since it has to return something. And should it be a different action type other than an "Action Result"??

Thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • csdnceshi55 ~Onlooker 2019-11-25 07:21

    If I got your question correctly then you want to achieve two goals.

    1. To save data on submit
    2. To close the modal on submit

    To achieve this you can call the normal controller action and also write a jquery which will help you to close modal when submit button clicked.

    JQuery code can be like: $('#YourSubmitButtonID').click(CLOSEMODAL)

    点赞 评论 复制链接分享

相关推荐