C# 从post方法将值传递给控制器
这是我的表格:C# 从post方法将值传递给控制器,c#,asp.net-mvc,C#,Asp.net Mvc,这是我的表格: @using (Html.BeginForm()) { <h3 class="text-blue title-article editable">thisStr</h3> <input type="submit" value="xxxx" class="btn btn-success" name="xxxx"/> } 我想我的问题是这一行: <input type="submit" value="xx
@using (Html.BeginForm())
{
<h3 class="text-blue title-article editable">thisStr</h3>
<input type="submit" value="xxxx" class="btn btn-success" name="xxxx"/>
}
我想我的问题是这一行:
<input type="submit" value="xxxx" class="btn btn-success" name="xxxx"/>
有人能帮帮我吗,谢谢 将其放在以下表格中:
@Html.HiddenFor(x=>x.Title)
视图:
在您的表单中添加一个
@Html.HiddenFor((p)=>Model.Title)
,然后将文本与帖子一起提交给您。谢谢您!我认为这个问题与我的内联编辑器有关,当我遵循你写的内容时,vl=一个空字符串。但是您的代码可以工作,因为db中的标题也显示空字符串。
@Html.HiddenFor(x=>x.Title)
@using (Html.BeginForm("YourAction","YourController",FormMethod.Post))
{
<h3 class="text-blue title-article editable">@Model.Title</h3>
@Html.HiddenFor(x=>x.Title)
<input type="submit" value="xxxx" class="btn btn-success" name="xxxx"/>
}
[HttpPost]
public ActionResult YourAction(FormCollection form)
{
sting vl= form["Title"].ToString();
return View();
}