首先下载HtmlArea3.0,解压到Web项目的某个目录。
lang/gb.js 是中文语言文件,官方默认是ANSI编码的,如果你的web.config设置为utf-8(默认),则需要用记事本打开gb.js,另存为utf-8格式。
以下是引用片段:
<script type="text/javascript"> _editor_url = "../HtmlArea/"; _editor_lang = "gb";</script>
<script type="text/javascript" src="../HtmlArea/htmlarea.js"></script>
<asp:TextBox ID="HtmlArea" CssClass="htmlarea" runat="server" Height="200px" TextMode="MultiLine" Width="100%"></asp:TextBox>
以下是引用片段:
protected void Page_Load(object sender, EventArgs e){
if (!Page.IsPostBack) {
StringBuilder sb = new StringBuilder();
sb.Append("var editor = null;");
sb.Append("function initEditor() {");
sb.Append("editor = new HTMLArea('" + ArticleBody1.FindControl("HtmlArea").ClientID + "');");
sb.Append("editor.generate();}");sb.Append("document.body.onload=initEditor;");
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "HtmlAreaScript", sb.ToString(), true);}
}
以下是引用片段:
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "HtmlAreaScript", "initEditor();", true);