Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从post方法将值传递给控制器_C#_Asp.net Mvc - Fatal编程技术网

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();
        }