weixin_33724046 2019-11-24 17:29 采纳率: 0%
浏览 41

.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条回答 默认 最新

  • ~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)

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料