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.