2
我在mvc3中遇到问题。林不知道这是特别mvc3,但目前我用剃刀引擎。无论如何,我面临的问题是,我有一个表单,我使用TextBoxFor,CheckBoxFor等来呈现它。渲染工作完美无瑕,除了当我尝试发布数据时,我基本上发布了一个空值的空表单。使用html助手时没有帖子值
这里是我的模型:
public class SendReplyPmForm : PM
{
public new string Text { get; set; }
public bool IsOriginalDelete { get; set; }
public int ReplyNr { get; set; }
public string ReceiverName { get; set; }
}
我有视图和模型之间的额外视图模型层,它包含有关这一模型
public class IndexViewModel
{
public SendReplyPmForm SendReplyPmForm { get; set; }
...
北京多paramater是我的看法
@using (Html.BeginForm("SendReply", "Pm", FormMethod.Post, new { id = "formSendMsg" }))
{
@Html.TextBoxFor(model => model.SendReplyPmForm.ReceiverName, new { id = "ReceiverName" })
<span id="spanChkText">Delete Original Message: @Html.CheckBoxFor(model => model.SendReplyPmForm.IsOriginalDelete, new { id = "chkIsOriginalDelete", value = 1 })</span>
@{Html.RenderPartial("~/Areas/Forums/Views/Shared/Toolbar.cshtml");}
<span class="spanLabel">Message</span>
@Html.TextAreaFor(model => model.SendReplyPmForm.Text, new { id = "Text", rows = "10", cols = "65" })
@{Html.RenderPartial("temp.cshtml");}
@Html.HiddenFor(model => model.SendReplyPmForm.ReplyNr, new { id = "inputReplyNr", value = 0 })
<input type="submit" value="Send" />
}
这里我有控制器
[HttpPost]
public ActionResult SendReply(SendReplyPmForm SendReplyForm) {
var ViewModel = new IndexViewModel();
.
.
.
return View("Index", ViewModel);
}
奇怪的是,如果我使用纯HTML而不是Html助手,那么帖子顺利运行没有任何问题。
我在阅读这篇文章(ASP.NET MVC’s Html Helpers Render the Wrong Value!)之前,我发布了这个,但我不太清楚,我有同样的问题。 (f.e .:我没有在我的控制器中执行操作,它有相同的名称),但这个事实也与纯Html一起使我思考。
你们有什么想法,我怎样才能使用这种形式与Html助手?
是的,这是一个,欢呼=) – JahManCan 2011-02-01 12:26:09