问题描述
我在index.cshtml中有两个部分,例如:
@ Html.Partial(_ EnquiryForm,new SharedModels.SC.Enquiry())
@Html .Partial(_ MemberLoginForm,新的SharedModels.SC.User())
有谁知道为什么表单提交继续进入Index actionresult而不是他们自己行动结果?
我尝试了什么:
两个部分都有形式其中的输入,例如:
< form>< input type =submitid =_ MemberLoginFormname =_ MemberLoginFormvalue =Login>< / form>
和
< form>< input type =submitid =submitname =_ EnquiryFormvalue =Submit>< / form>
但两种形式总是去
[HttpPost]
公共ActionResult指数(查询查询)
{}
而不是我期望的:
[HttpPost]
public A. ctionResult _EnquiryForm(查询查询)
{}
或
[HttpPost]
公共ActionResult _MemberLoginForm(用户用户) )
{}
I have two partials inside index.cshtml such as:
@Html.Partial("_EnquiryForm", new SharedModels.SC.Enquiry())
@Html.Partial("_MemberLoginForm", new SharedModels.SC.User())
Does anyone know why the form submissions keep going to the Index actionresult instead of to their own actionresults?
What I have tried:
both partials have form inputs in them, such as:
<form><input type="submit" id="_MemberLoginForm" name="_MemberLoginForm" value="Login" ></form>
and
<form><input type="submit" id="submit" name="_EnquiryForm" value="Submit" ></form>
But both forms always go to
[HttpPost]
public ActionResult Index(Enquiry enquiry)
{}
instead of to what I'd expect:
[HttpPost]
public ActionResult _EnquiryForm(Enquiry enquiry)
{}
or
[HttpPost]
public ActionResult _MemberLoginForm(User user)
{}
推荐答案
这篇关于如何针对不同的部分表单提交获得不同的MVC操作结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!