Read Ueditor edit box contents to database and upload picture configuration

Source: Internet
Author: User
Tags documentation

Main content:

How to read from a database before the contents of the editor text box are plain text

Ueditor the configuration of uploaded images

1, how to read from the database before the editor text box content is plain text.

Before I write down the title problem solution, I'll start by explaining one of the issues encountered in the foreground display:

When the video is displayed, the HTML code is read from the database, and the razor parsing is returned to the foreground page as follows:

<p><span style="font-family: Official script, Simli; font-size:24px; Color:rgb (255, 0, 0);">, thousand Bones </span></p>

We can call rawstring to show the code as a string, and the HTML string to be read from the database is printed directly to the body tag of the HTML page:

Raw is a method that encapsulates the Rawstring class

@Raw (Model.note)

The above paragraph is no nonsense, the next introduction to the use of Ueditor also have the same problem.

Environment:

When you save to a database using the Ueditor editor and then click Edit, the saved content is displayed in the edit box in the Ueditor editor.

1, the input in the Ueditor edit box is actually an HTML string:

2, if you use the following method to get the contents of the edit box:

Get HTML content

var html = ue.getcontent ();

3, then the database is stored in an HTML string:

4, this is the problem, when you click on the modification, get the HTML string from the database will be displayed directly in the Ueditor edit box:

So it's best to call rawstring the same as the article started, and output the HTML read from the database to the HTML page as a string:

A rawstring is encapsulated in the raw method

<script id= "container" name= "content" type= "Text/plain" >

@RuPengRazor. Rphelper.raw (Model.segmentModel.Note)

</script>

Of course, there is no problem with the plain text content that gets ueditor when writing:

Get Plain text content
var txt = ue.getcontenttxt ();

However, at this time the database is the user input of the plain text content, to the text given to the style will not be stored in the database, the modified read out of course is also plain text, also do not need rawstrig parsing.

We use Ueditor cumin is his powerful rich text function, so it is best to take the HTML content to get the contents of the Ueditor edit box, and then into the database, when read using rawstring parse the database HTML string display to the edit box.

2. about the Ueditor Upload a picture configuration

1. To add a reference to Newtonsoft.json after putting the Ueditor code in the site Directory

2, about uploading picture path problem

Ueditor official documentation is mentioned in the Net/config.json file:

"Imageurlprefix": "/ueditor/net/",/* Image access Path prefix */

When you add the Newtonsoft.json reference, the upload image function can be used, but if you do not configure Imageurlprefix items, the uploaded image path will be/ueditor/net/upload/image/... Format into the database, and later read from the database this path will not display the picture properly.

This is mentioned in the official documentation, in simple terms:

Imageurlprefix the configuration value of the prefix to add the site domain name, when uploading the image will be stored together with the domain name in the database, read to get is a full path with the domain name, the picture will be normal display, like this:

"Imageurlprefix": "http://localhost:43316/ueditor/net/",/* Image access Path prefix */

The instructions in this official document are as follows:

In some cases, simply by returning the path is not able to get the normal picture link, you need to configure Imageurlprefix to insert the path of the picture to add a prefix.

There are two scenarios in which you need to configure Imageurlprefix:

Under ASP and. NET, the application directory is not the site root, and you need to prefix the path.

In the case of cross-domain uploads, you need to configure the Imageurlprefix prefix. Assuming that the page is under the a.com domain, the file is uploaded to the B.Com domain, so that the Imageurlprefix is configured to "http://b.com" to get the normal path.

Read Ueditor edit box contents to database and upload picture configuration

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.