在Mvc按钮事件不工作问题 [英] in Mvc Button Event not Work Problem
问题描述
cshtml代码:
@using(Html.BeginForm(Btn_LoginClick,Home,FormMethod.Post))
{
< input type =submitid =Btn_Loginname =submitvalue =ورودclass =button/>
} < br $>
控制器代码:
折叠|复制代码
公共ActionResult注册()
{
返回查看();
}
[HttpPost]
public ActionResult Btn_LoginClick(){
返回RedirectToAction(Register);
}
cshtml Code :
@using (Html.BeginForm("Btn_LoginClick", "Home", FormMethod.Post))
{
<input type="submit" id="Btn_Login" name="submit" value="ورود" class="button" />
}
Controller Code :
Collapse | Copy Code
public ActionResult Register()
{
return View();
}
[HttpPost]
public ActionResult Btn_LoginClick() {
return RedirectToAction("Register");
}
推荐答案
Hi,
Do not passed FormMethod in BrginForm. As from your code it looks like you are returning view. So you getting result, so it will be HttpGet. SO do not pass that FormMethod.
@using (Html.BeginForm("ActionName", "Controller"))
{
}
无需在此处使用Post,因为您将其设置在您的行动之上。
你可以使用return
}
No need of using Post here in view since you set that above your action.
you can use return
View("url",object);
你也可以这样使用.. !!!
重定向
you can use like this also..!!!
incase of redirection
return RedirectToaction("Action",new{id=idvalue})
如果你想从这里传递任何参数值,你可以使用上述方法。
if you want to pass any parameter value from here u can use above methods.
这篇关于在Mvc按钮事件不工作问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!