Use ueditor in asp.net

Source: Internet
Author: User

Address: http://www.daidaiwa.com/ArticleDetail/2013/9/1/16.html

Baidu initially made a selection of "Editor", and there were many options available, including ckeditor, kindeditor, markItUp, and ueditor.

At first, considering that ckeditor has many users, has been used in projects, and is also a good open-source project outside China, ckeditor was selected. After using ckeditor for a while, I found that many places do not conform to Chinese habits. The first line indented two Chinese characters, which is one of the most intolerable. There is also the "insert code" function that we often use. The symbols in the inserted code are escaped.

Ueditor is in line with our usage habits. We used to try it out before. Due to the late start, there were many bugs and we didn't choose him. Recently, I went to the ueditor official website and updated it to 1.2.6.1. I tried it again and corrected many bugs. So now I use him again. Well, it's over. Use the following methods:

1. Download, official website address: http://ueditor.baidu.com/website/download.html#ueditor I downloaded. net UTF-8.

2. decompress the package and put it into the project.

3. Call it where you want to use it. First, reference two sections of js, one configuration, and one ueditor.

1 <script src="../Public/ueditor/ueditor.config.js" type="text/javascript"></script>
2     <script src="../Public/ueditor/ueditor.all.min.js" type="text/javascript"></script>

4. Then initialize ueditor. The temp in the following code is used to obtain the database content.

1 <div id="myEditor" style="height:500px;"></div>
2                     <script type="text/javascript">
3                         var temp = document.getElementById("<%=hd_content.ClientID %>").value;
4                         var ue = new baidu.editor.ui.Editor();
5                         Ue. render ("myEditor"); // enter the id of the control to be changed to the editor.
6                         ue.ready(function () { ue.setContent(temp); })
7                     </script>

5. The last step is to save the data.

1 <asp:Button ID="BtnSave" runat="server" Text="Save" onclick="BtnSave_Click" OnClientClick="return getContent();" CssClass="cssbtn" /> 
2 <script type="text/javascript">
3         function getContent() {
4             var temp = UE.getEditor('myEditor').getContent();
5             //alert(temp);
6             document.getElementById("<%=hd_content.ClientID %>").value = temp;
7         }
8     </script>

Appendix: The hd_content I used is for intermediate content only. Put it in the form of the body.

1 <asp:HiddenField ID="hd_content" runat="server" Value="" />

Conclusion: 1. ueditor's current version does not need to be configured any more. ueditor developers have already completed the configuration, which is much more convenient than before. 2..net also needs to pay attention to the upload issue. A file is compiled by default, to change the content (if you are publishing a website), right-click the file attribute and you will be able to find it.

Haha, ueditor is really good.

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.