日期:2014-05-20 浏览次数:20923 次
XikeMvcEntities db = new XikeMvcEntities(); public ActionResult Index(int id) { var model = db.Company.Where(m => m.ClassId == id).Single(); ViewData["NewsContent"] = model.Details; return View(); } [ValidateInput(false)] [HttpPost] public ActionResult Index(int id, FormCollection collection) { if (ModelState.IsValid) { var model = db.Company.Where(m => m.ClassId == id).Single(); model.Details =Input.LostHTML(collection["NewsContent"]); if (db.SaveChanges() > 0) { ShowAlert("更新成功!"); return RedirectToAction("Index","Manager"); } else { return View(); } } else { return View(); } } public ActionResult ShowAlert(string msg) { var script = string.Format("alert('{0}');", msg); return JavaScript(script); }
<div style="margin-left:10px">@Html.FckText("NewsContent", "700", "400")</div>
public static MvcHtmlString FckText(this System.Web.Mvc.HtmlHelper helper, string name, string width, string height) { if (string.IsNullOrEmpty(name)) { return MvcHtmlString.Create("name属性为必须"); } StringBuilder strBuilder = new StringBuilder(); strBuilder.Append("<script tyle=\"text/javascript\">"); strBuilder.Append(" var f = new FCKeditor(\"" + name + "\"," + width + "," + height + ");"); strBuilder.Append("f.Create()"); strBuilder.Append("</script>"); return MvcHtmlString.Create(strBuilder.ToString()); }