日期:2014-05-20 浏览次数:20993 次
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.WeiboID)
@Html.HiddenFor(model => model.CreateDate)//这里使用隐藏域
@Html.HiddenFor(model => model.ReaderNumber)//这里使用隐藏域
<div class="editor-line">
@Html.LabelFor(model => model.Title)<br />
@Html.EditorFor(model => model.Title)
@Html.ValidationMessageFor(model => model.Title)
</div>
<div class="editor-line">
@Html.LabelFor(model => model.Content)<br />
@Html.TextAreaFor(model => model.Content, new { style = "width:850px; height:400px;" })
@Html.ValidationMessageFor(model => model.Content)
</div>
<p>
<input type="submit" value="保 存" class="editor-botton" />
</p>
}
public ActionResult WeiboEdit(Weibo model)
{
if (ModelState.IsValid)
{
model.EditDate = DateTime.Now;
db.Entry(model).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Weibo");
}
return View(model);
}