Baidu UEditor edits old articles

Source: Internet
Author: User

After using UEditor, you sometimes need to edit the old article, view the official document, and output the article content, but there is no way to submit it. So refer to the idea when editing the new article, come up with the following method:

I. Define variables in the background
A variable is defined in the background to indicate the content of the old article:
[Csharp]
Public string words = "";

Public string words = "";

Ii. Import js and css files
[Javascript]
<Script type = "text/javascript" src = ".../ueditor/editor_config.js"> </script>
 
<Script type = "text/javascript" src = ".../ueditor/editor_all.js"> </script>

<Script type = "text/javascript" src = ".../ueditor/editor_config.js"> </script>

<Script type = "text/javascript" src = ".../ueditor/editor_all.js"> </script> [css] view plaincopyprint? <Link rel = "Stylesheet" type = "text/css" href = ".../ueditor/themes/default/css/ueditor.css"/>

<Link rel = "Stylesheet" type = "text/css" href = ".../ueditor/themes/default/css/ueditor.css"/> 3. Page usage
[Javascript]
<Script type = "text/javascript">
Var editor = new UE. ui. Editor ();
Editor. render ("editor ");
</Script>
<Script type = "text/plain" id = "editor" name = "myEditor">
<% = Words %>
</Script>

<Script type = "text/javascript">
Var editor = new UE. ui. Editor ();
Editor. render ("editor ");
</Script>
<Script type = "text/plain" id = "editor" name = "myEditor">
<% = Words %>
</Script> [csharp]
<Div>
<Asp: ImageButton ID = "imgSubmit" runat = "server" ImageUrl = "~ /Images/submit.png "OnClick =" imgSubmit_Click "/>
</Div>

<Div>
<Asp: ImageButton ID = "imgSubmit" runat = "server" ImageUrl = "~ /Images/submit.png "OnClick =" imgSubmit_Click "/>
</Div>

Iv. Background reception
[Csharp]
DataClassesDataContext system = new DataClassesDataContext (ConfigurationManager. ConnectionStrings ["SystemConnectionString"]. ConnectionString. ToString ());

DataClassesDataContext system = new DataClassesDataContext (ConfigurationManager. ConnectionStrings ["SystemConnectionString"]. ConnectionString. ToString (); [csharp]
Protected void imgSubmit_Click (object sender, ImageClickEventArgs e)
{
Aboutus AB = system. aboutus. FirstOrDefault ();
String workContent = HttpUtility. HtmlDecode (Request. Form ["myEditor"]. ToString (); // content
// WorkContent = Server. HtmlEncode (workContent); // transcode the Html tag, but the style is lost in the output.
String sOrginial = "<script type = \" text/javascript \ "> ";
String sTo = "<script type =" text/javascript "> ";
WorkContent = workContent. Replace (sOrginial, sTo); // these two steps output js Code as is
String sTime = DateTime. Now. ToString ("yyyy-MM-dd HH: mm: ss ");
AB. words = workContent;
AB. updateTime = sTime;
Try
{
System. SubmitChanges ();
ClientScript. registerStartupScript (this. getType (), "error", "$ (function () {asyncbox. alert ('updated successfully', 'hprompt ') ;}); window. setTimeout (function () {window. location. href = 'detail. aspx '}, 500); ", true );
}
Catch (Exception ex)
{
ClientScript. RegisterStartupScript (this. GetType (), "error", "$ (function () {asyncbox. alert ('Update failed, please try again later! ',' Hint ');}); window. setTimeout (function () {window. location. href = 'detail. aspx'}, 500); ", true );
}

Protected void imgSubmit_Click (object sender, ImageClickEventArgs e)
{
Aboutus AB = system. aboutus. FirstOrDefault ();
String workContent = HttpUtility. HtmlDecode (Request. Form ["myEditor"]. ToString (); // content
// WorkContent = Server. HtmlEncode (workContent); // transcode the Html tag, but the style is lost in the output.
String sOrginial = "<script type = \" text/javascript \ "> ";
String sTo = "<script type =" text/javascript "> ";
WorkContent = workContent. Replace (sOrginial, sTo); // these two steps output js Code as is
String sTime = DateTime. Now. ToString ("yyyy-MM-dd HH: mm: ss ");
AB. words = workContent;
AB. updateTime = sTime;
Try
{
System. SubmitChanges ();
ClientScript. registerStartupScript (this. getType (), "error", "$ (function () {asyncbox. alert ('updated successfully', 'hprompt ') ;}); window. setTimeout (function () {window. location. href = 'detail. aspx '}, 500); ", true );
}
Catch (Exception ex)
{
ClientScript. RegisterStartupScript (this. GetType (), "error", "$ (function () {asyncbox. alert ('Update failed, please try again later! ',' Hint ');}); window. setTimeout (function () {window. location. href = 'detail. aspx'}, 500); ", true );
}
Among them, asyncbox. alert ('',''); is an asynchronous pop-up box plug-in of jQuery.

 

 

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.