首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

在MVC中给FCK赋值,该如何处理

2012-02-20 
在MVC中给FCK赋值ControllerC# codeXikeMvcEntities db new XikeMvcEntities()public ActionResult Ind

在MVC中给FCK赋值
Controller

C# code
        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);        }


View
C# code
<div style="margin-left:10px">@Html.FckText("NewsContent", "700", "400")</div>


HtmlHelper
C# code
        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());        }


请问怎么给FCK赋值

[解决办法]
我来占座了.

热点排行