Namespace System. Web. Mvc
{
Using System;
Using System. Globalization;
/// <Summary>
/// HTMLHelper of Fckeditor
/// Http://chsword.cnblogs.com/
/// </Summary>
Static public class FckTextBoxExt
{
/// <Summary>
/// HTMLHelper of Fckeditor, which can be bound to ViewData with the same name
/// </Summary>
/// <Param name = "u"> HtmlHelper </param>
/// <Param name = "name"> Html NAME </param>
/// <Returns> </returns>
Public static string FckTextBox (this HtmlHelper u, string name)
{
Return u. FckTextBox (name, null );
}
/// <Summary>
/// HTMLHelper of Fckeditor
/// </Summary>
/// <Param name = "u"> </param>
/// <Param name = "name"> Html name </param>
/// <Param name = "value"> content </param>
/// <Returns> </returns>
Public static string FckTextBox (this HtmlHelper u, string name, object value)
{
Return u. FckTextBox (name, value. ToString ());
}
/// <Summary>
/// HTMLHelper of Fckeditor
/// </Summary>
/// <Param name = "u"> </param>
/// <Param name = "name"> Html name </param>
/// <Param name = "value"> content </param>
/// <Returns> </returns>
Public static string FckTextBox (this HtmlHelper u, string name, string value)
{
If (value = null)
{
Value = Convert. ToString (u. ViewDataContainer. ViewData [name], CultureInfo. InvariantCulture );
}
Return string. format (@ "<textarea name =" "{0}" "id =" "{0}" "rows =" 50 "" cols = "" 80 "" style = "" width: 100%; height: 600px "" >{1} </textarea>
<Script type = "" text/javascript "">
Var oFCKeditor = new FCKeditor ('{0 }');
// OFCKeditor. BasePath = sBasePath;
OFCKeditor. Height = 400;
OFCKeditor. ReplaceTextarea ();
</Script>
", Name, value );
}
}
}
Usage
View page write
<% = Html. FckTextBox ("content") %>
Controller write
ViewData ["content"] = "<div>... </div> ";
You can bind it
I hope it will be helpful for you to expand MVC.