How to get CKEDITOR contents when sending to asp.net

I used CKEDITOR in my ASP.NET project, the page contains asp:TextBox with TextMode="Multiline" and linkbutton. When I click the linkbutton button, I cannot get the TextBox value in the postback. There were no errors ... How to get content on the server side? I was thinking about using jQuery to track changes in CK content and copy it to a hidden text box ... but it didn't seem to be right.

I am using javascript version of CK v4.2 and not .net version.

Addition:
In the example downloaded with the CKEditor.zip file, you can see that getting server-side text is easy with $ _POST.
Why is there no ASP.NET?

Update:
This problem occurs when using RadScriptManager, RadAjaxManager and RadAjaxPanel (from telerik).

+4
source share
6 answers

On the ASPX page, install the CKEditor control as follows:

 <CKEditor:CKEditorControl ID="CKEditor1" runat="server"/> 

On the page with the code:

 protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { string text1 = CKEditor1.Text; string text2 = CKEditor1.Value; ... } } 

Remember to add / enable the correct links to the CKEditor binaries

+2
source

I ran into the same problem. On a simple page, I tested LinkButton and Button. The problem is that LinkButton does not submit the form directly. It displays the link and raises the __doPostBack event, so this is a problem for CKEditor. I tried setting a text box like Nirmal , but that didn't work either. This is how I solved it.

Title:

 <script type="text/javascript"> $(document).ready(function () { $("#tBody").ckeditor(); }); function setValue() { $("#hfBody").val(CKEDITOR.instances.tBody.getData()); } </script> 

Inside the form:

 <asp:TextBox ID="tBody" runat="server" TextMode="MultiLine"/> <asp:HiddenField ID="hfBody" runat="server" /> <asp:LinkButton ID="btnSend" Text="Link" runat="server" OnClick="X_Click" OnClientClick="setValue()"/> 

FROM#

 protected void X_Click(object sender, EventArgs e) { divResult.InnerHtml = hfBody.Value; tBody.Text = hfBody.Value; } 
+1
source

something like this might help

 string newText = ((CKedit.CKeditor)(e.Item.FindControl("txtBox"))).Value; 

else use updatepanel to keep its value in postback

0
source

One of my collaborators solved it by setting the setup property when init tinymce looks like this:

 setup: function (ed) { ed.on('change', function (e) { ed.save(); }); } 

This will save the content in the editor when the change event is called.

0
source

You will get the data, try below code:

var editorText = CKEDITOR.instances.txtinstruction.getData (); _msemailsetup.BodyMessage = editorText;

0
source

before the postback event fires, call this function for the set value

 function setValue() { $("#txtinstruction").val(CKEDITOR.instances.txtinstruction.getData()); } 

txtinstruction is the identifier of a text field or text area

-one
source

Source: https://habr.com/ru/post/1498362/


All Articles