我正在尝试在Controller和View之间共享一个名为“Version”的类型的实例。
从控制器到视图效果很好。但是在回来的路上,我得到了实例,因为它被发送到视图而没有表单中的更改。
观点:
@model Models.Pages.Versions
@using (Html.BeginForm(Model))
{
ViewBag.Title = "Create";
<div>
Title:
@Html.TextBox("titleTb",Model.Title) </div>
@(Html.Kendo().Editor()
.Name("editor")
.Value(Model.Content)
.HtmlAttributes(new { style = "width: 740px;height:440px" })
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/Content/UserFiles/Images/{0}")
.Read("Read", "ImageBrowser")
.Create("Create", "ImageBrowser")
.Destroy("Destroy", "ImageBrowser")
.Upload("Upload", "ImageBrowser")
.Thumbnail("Thumbnail", "ImageBrowser")) )
<br />
<input type="submit" value="Create" /> }
控制器:
public ActionResult Create()
{
return View(new Models.Pages.Versions() { Title = "New Title", Content = "Test"});
}
[HttpPost]
public ActionResult Create(Models.Pages.Versions version)
{
ViewBag.Title = version.Content;
Models.Pages.Registry createdPage = Models.Pages.Registry.InsertNew(Models.Ref.connectionString);
version.PageId = createdPage.Id;
version.Author = User.Identity.Name;
version.TimeStamp = DateTime.Now;
version.Insert();
return View(createdPage.Id);
}
更新 在提交表单时查看查询字符串,表单中的输入似乎根本不会影响它。