MVC中的html.beginform()出错 [英] Error in html.beginform() in MVC

查看:124
本文介绍了MVC中的html.beginform()出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从另一个视图调用视图。使用按钮单击。



我尝试过:



在我的视图中,



@using(Html.BeginForm(NotiHead,Header))

{

< button class =btn blue btn-block btn-outline>通知头< / button>

}



这是我的控制器。



公共ActionResult NotiHead()

{



NotiHdrEntity obj = new NotiHdrEntity();

返回查看(obj);



}



我的视图名称是NotiHead



非常感谢!

I need to call a View From Another View.Using Button Click.

What I have tried:

In My View,

@using (Html.BeginForm("NotiHead", "Header"))
{
<button class="btn blue btn-block btn-outline ">Notification Head</button>
}

this is my Controller.

public ActionResult NotiHead()
{

NotiHdrEntity obj = new NotiHdrEntity();
return View(obj);

}

And My View Name is NotiHead

Many Thanks !

推荐答案

你需要添加按钮类型作为提交和设置表单方法类型以及获取或发布,看起来像是你的工作,因为你没有发布任何数据:



You need to add button type as submit and set form method type as well get or post, it looks like get would work as you are not posting any data:

@using (Html.BeginForm("NotiHead", "Header",FormMethod.Get))
{
<button type="submit" class="btn blue btn-block btn-outline ">Notification Head</button>
}


而不是这种方式我们可以使用



instead of this way we can use

<a href="@Url.Action(" viewname","actionmethod")"=""> </a>











OR

@Html.ActionLink("Lable", "viewName", "Actionmethod")









谢谢!





Thank You !


这篇关于MVC中的html.beginform()出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆