How to Use TinyMCE (Rich Text Editor) in Asp. Net

Source: Internet
Author: User

TinyMCE's use in Asp. Net is actually quite simple, download TinyMCE from the official website), and then copy the jscripts directory to your website directory.

Suppose you need to use the editor somewhere on your aspx page, add

<Asp: TextBox ID = "brand" TextMode = "MultiLine" runat = "server"/>

Add the following content to the header:

<Script src = "../js/tiny_mce/tiny_mce_src.js" type = "text/javascript"> </script>
<Script language = "javascript" type = "text/javascript">
TinyMCE.Init({
Mode: "textareas ",
Theme: "simple"
});
</Script>

Run the page to see an editor, and you can use brand. text to get the value (You may see an error prompt, then you only need. add ValidateRequest = "false" to the <% @ Page at the beginning of aspx)

Of course, if you have multiple textareas on your page, you may only want to replace one with an editor, then the above mode line is changed:

Mode: "exact", elements: "corresponding ID"
For other usage instructions, go to the official website.
----------------------------------------------------------------
Chinese garbled characters:
After TinyMCE's Language Pack is set, it is always abnormal when used in ASP.net, and the content of the Language Pack cannot be read.
After careful research, it turns out that the default HTTPResponse output of ASP.net 2.0 is UTF-8, not Chinese gb2312, or gb18030, HZ, so the settings are correct, however, an error occurs during page execution and the configuration of the Language Pack cannot be correctly read.
We can add the setting statement to Load the Page class to solve this problem.

  Response.ContentEncoding = Encoding.GetEncoding("gb2312")

After re-compilation, You can normally read the content in the Chinese language resource package.
-----------------------------------------------------
Related resource collection:
TinyMCE Chinese manual Co., http://www.inpeck.com/TinyMceManual/
Several useful plug-ins in tinymce: http://joom.org.ru/home/article/14-tinymce-plugin.html
Online Editor TinyMCE 3 Simplified Chinese Language Pack: http://www.metalstar.net /? D = 86
Tinymce small Chinese fonts solution http://www.humker.com/2008/03/07/tinymce-chinese-font-size
Made of custom controls: http://www.jonllen.com/jonllen/aspnet/tinymce.aspx

No matter which version of tinymce is used, the default Chinese font is too small. After editing and saving it, the default font becomes quite large.

Solution: In js \ themes \ advanced \ css \ editor_content.css

Body, td, pre {
Font-family: Verdana, Arial, Helvetica, sans-serif;
Font-size: 12px;
}

Change 10px to 12px.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.