Asp. NET integration Ueditor access to news content and error resolution

Source: Internet
Author: User
Tags gettext

I. Acquisition of content

The foreground joins the code and joins in the instantiation editor (this is what I copy others to write):

<script type= "Text/javascript" >//Instantiation Editor//The factory method Geteditor is used to create and reference the editor instance, and if the editor is referenced under a closure, call the Ue.geteditor directly                (' editor ') will be able to get relevant examples of var UE = Ue.geteditor (' txteditorcontents ');            function Isfocus (e) {alert (Ue.geteditor (' Editor '). Isfocus ());            UE.dom.domUtils.preventDefault (e)} function Setblur (e) {ue.geteditor (' editor '). blur (); UE.dom.domUtils.preventDefault (e)} function inserthtml () {var value = prompt (' Insert HTML code ', ' "            );            Ue.geteditor (' editor '). ExecCommand (' inserthtml ', Value)} function Createeditor () {enablebtn ();        Ue.geteditor (' editor ');         } function getallhtml () {Alert (Ue.geteditor (' Editor '). getallhtml ())}function getcontent () {var arr = [];            Arr.push ("Use the Editor.getcontent () method to get the contents of the editor");            Arr.push ("content is:");            Arr.push (Ue.geteditor (' Editor '). getcontent ());        Alert (Arr.join ("\ n")); }        function Getplaintxt () {var arr = [];            Arr.push ("Use the Editor.getplaintxt () method to get the formatted plain text content of the editor");            Arr.push ("content is:");            Arr.push (Ue.geteditor (' Editor '). Getplaintxt ());            Alert (arr.join (' \ n ')} function SetContent (isappendto) {var arr = [];            Arr.push ("Use Editor.setcontent (' Welcome to Ueditor ') method to set the contents of the editor");            Ue.geteditor (' editor '). SetContent (' Welcome to use Ueditor ', isappendto);        Alert (Arr.join ("\ n"));            } function setdisabled () {ue.geteditor (' editor '). setdisabled (' fullscreen ');        DISABLEBTN ("Enable");            } function setenabled () {ue.geteditor (' editor '). setenabled ();        ENABLEBTN (); } function GetText () {//When you click on the button the edit area has lost focus, if the direct use of getText will not get the content, so you have to choose back, then get the content var range = UE            . Geteditor (' editor '). Selection.getrange ();            Range.Select (); var txt = ue.geteditor (' editor '). selection.geTtext ();            Alert (TXT)} function Getcontenttxt () {var arr = [];            Arr.push ("Use the Editor.getcontenttxt () method to get the plain text content of the editor");            Arr.push ("The plain text content of the editor is:");            Arr.push (Ue.geteditor (' Editor '). Getcontenttxt ());        Alert (Arr.join ("\ n"));            } function Hascontent () {var arr = [];            Arr.push ("Use the Editor.hascontents () method to determine if there is content in the editor");            Arr.push ("Judgment result is:");            Arr.push (Ue.geteditor (' Editor '). hascontents ());        Alert (Arr.join ("\ n"));        } function SetFocus () {ue.geteditor (' editor '). focus ();            } function Deleteeditor () {disablebtn ();        Ue.geteditor (' editor '). Destroy ();            } function disablebtn (str) {var div = document.getElementById (' Btns ');            var btns = UE.dom.domUtils.getElementsByTagName (div, "button"); for (var i = 0, btn; btn = btns[i++];)     {if (btn.id = = str) {               UE.dom.domUtils.removeAttributes (BTN, ["Disabled"]);                } else {Btn.setattribute ("disabled", "true");            }}} function Enablebtn () {var div = document.getElementById (' Btns ');            var btns = UE.dom.domUtils.getElementsByTagName (div, "button"); for (var i = 0, btn; btn = btns[i++];)            {UE.dom.domUtils.removeAttributes (BTN, ["Disabled"]);        }} function Getlocaldata () {Alert (Ue.geteditor (' Editor '). ExecCommand ("Getlocaldata"));            } function Clearlocaldata () {ue.geteditor (' editor '). ExecCommand ("Clearlocaldata"); Alert ("Empty draft box")}</script>

I just need to get the editor's content on the line, the use of the Red method, and the editor of the HTML tag, image path and so on are automatically generated, direct access to it, finished as follows:

<!--loading editor container--><script id= "container" name= "content" type= "Text/plain" ></script><!--configuration file-- ><script type= "Text/javascript" src= ". /edit/ueditor/ueditor.config.js "></script><!--Editor source file--><script type=" Text/javascript "src=". /edit/ueditor/ueditor.all.js "></script><!--instantiation editor--><script type=" Text/javascript "> var UE =  Ue.geteditor ('txteditorcontents');    function getcontent () {var arr = [];    Arr.push ("Use the Editor.getcontent () method to get the contents of the editor");    Arr.push ("content is:");    Arr.push (Ue.geteditor (' Editor '). getcontent ());  Alert (Arr.join ("\ n")); }</script>

Create a Textbox,id on the page consistent with the red above, this text box is placed on top of the editor.

<asp:textbox id= "txteditorcontents" name= "txteditorcontents" runat= "Server" height= "234px" textmode= "MultiLine" Width= "450px" clientidmode= "Static" >
</asp:TextBox>

Then into the background, there is a confirmation to add News button bar, add click event, see if can get the content:

string s = this.txtEditorContents.Text; Response.Write (s);

The entire string receives the contents of the text box, and the text box is like a transit station.

Add Breakpoint-f10 Enter Debug-Added News-OK add: Found error, but content can be seen acquired.

To resolve this error, the newly created Web Forms page will default to one line of code at the top:

<%@ page language= "C #"  validaterequest= "false" autoeventwireup= "true" codebehind= "News.aspx.cs" inherits= "Appworld.AdminMe.News"%>

Put the red one in the line, debugging again, clearly visible, the content into the variable, and then dump the database can be.

Asp. NET integration Ueditor access to news content and error resolution

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.