locked
Editor ajax control ToolKit RRS feed

  • Question

  • User910710390 posted

    I save the Editor.content in sql server 2008 but it is saving the text in editor by html code

    <p style="margin: 0px; text-align: right;">شسيشسيسشيشسي<br />  </p>

    I want save شسيشسيسشيشسي only in sql server 

      Protected Sub Bsave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Bsave.Click
            Try
    
                Dim specf As String, specs As String, spect As String, speco As String, speci As String
                specf = Editspf.Content.ToString
                specs = Editsps.Content
                spect = Editspt.Content
                speco = Editspo.Content
                speci = Editspi.Content
                Dim o As New spec
                o.update(Request.QueryString("idc"), specf, specs, spect, speco, speci)
            Catch ex As Exception
                Response.Write(ex.Message)
            End Try
        End Sub

    How can I do that please help me

    Monday, April 13, 2015 5:36 AM

Answers

  • User61956409 posted

    Hi Mohammed,

    Thanks for your post.

    You could try the following sample (in c#) to get the text from editor content.

    <div>
        <cc1:Editor ID="Editor1" runat="server" />
        <br />
        <asp:Button ID="btnsave" runat="server" Text="Save" OnClick="btnsave_Click" />
    </div> 
    
    protected void btnsave_Click(object sender, EventArgs e)
    {
        string editorcontent = Editor1.Content.ToString();
    
        string text = GetTextonly(editorcontent);
    }
    
    public static string GetTextonly(string editorcontent)
    {
        string strtext = "";
        strtext = Regex.Replace(editorcontent, @"<(.|\n)*?>", string.Empty);
        return strtext;
    }
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 13, 2015 10:47 PM

All replies

  • User61956409 posted

    Hi Mohammed,

    Thanks for your post.

    You could try the following sample (in c#) to get the text from editor content.

    <div>
        <cc1:Editor ID="Editor1" runat="server" />
        <br />
        <asp:Button ID="btnsave" runat="server" Text="Save" OnClick="btnsave_Click" />
    </div> 
    
    protected void btnsave_Click(object sender, EventArgs e)
    {
        string editorcontent = Editor1.Content.ToString();
    
        string text = GetTextonly(editorcontent);
    }
    
    public static string GetTextonly(string editorcontent)
    {
        string strtext = "";
        strtext = Regex.Replace(editorcontent, @"<(.|\n)*?>", string.Empty);
        return strtext;
    }
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 13, 2015 10:47 PM
  • User910710390 posted

    Hi Mohammed,

    Thanks for your post.

    You could try the following sample (in c#) to get the text from editor content.

    <div>
        <cc1:Editor ID="Editor1" runat="server" />
        <br />
        <asp:Button ID="btnsave" runat="server" Text="Save" OnClick="btnsave_Click" />
    </div> 
    
    protected void btnsave_Click(object sender, EventArgs e)
    {
        string editorcontent = Editor1.Content.ToString();
    
        string text = GetTextonly(editorcontent);
    }
    
    public static string GetTextonly(string editorcontent)
    {
        string strtext = "";
        strtext = Regex.Replace(editorcontent, @"<(.|\n)*?>", string.Empty);
        return strtext;
    }
    

    Best Regards,

    Fei Han


    This is not correct 

    Return "<p style="margin: 0px; text-align: right;">سشيمانسايمسيكسي سي</p> <p style="margin: 0px; text-align: right;">شسيمناناشسيسي</p>"

     this code html

    I want to return سشيمانسايمسيكسي سي

    شسيمناناشسيسي

    please help me

    Thank's     

    Tuesday, April 14, 2015 4:15 AM
  • User61956409 posted

    Hi Mohammed,

    Return "<p style="margin: 0px; text-align: right;">سشيمانسايمسيكسي سي</p> <p style="margin: 0px; text-align: right;">شسيمناناشسيسي</p>"

     this code html

    I want to return سشيمانسايمسيكسي سي

    شسيمناناشسيسي

    Have you tried my code? it could get non-html text from Editor Content.

    With Regards,

    Fei Han

    Monday, April 20, 2015 3:07 AM
  • User910710390 posted

    Hi Mohammed,

    Mohammed Saleh

    Return "<p style="margin: 0px; text-align: right;">سشيمانسايمسيكسي سي</p> <p style="margin: 0px; text-align: right;">شسيمناناشسيسي</p>"

     this code html

    I want to return سشيمانسايمسيكسي سي

    شسيمناناشسيسي

    Have you tried my code? it could get non-html text from Editor Content.

    With Regards,

    Fei Han

    Yes I tried ,

    the content  always html-text

    can not convert html-text to string when save editor.content  in field database

    but we can convert it when run crystal report or back html-text from database to lable or any tools

    thank's 

    Tuesday, April 21, 2015 4:42 AM
  • User61956409 posted

    Hi Mohammed,

    In fact, it works fine on my side.

    <div>
        <cc1:Editor ID="Editor1" runat="server" />
        <br />
        <asp:Button ID="btnsave" runat="server" Text="Save" OnClick="btnsave_Click" />
        <br />
        <div id="content" runat="server"></div>
        <br />
        <div id="nonhtml" runat="server"></div>
    </div> 
    
    protected void btnsave_Click(object sender, EventArgs e)
    {
        string editorcontent = Editor1.Content.ToString();
    
        string text = GetTextonly(editorcontent);
    
        content.InnerText = editorcontent;
        nonhtml.InnerText = text;
    }
    
    public static string GetTextonly(string editorcontent)
    {
        string strtext = "";
        strtext = Regex.Replace(editorcontent, @"<(.|\n)*?>", string.Empty);
        return strtext;
    } 
    

    With Regards,

    Fei Han



    Tuesday, April 21, 2015 5:26 AM
  • User555306248 posted

    The Html Editor is one of the unique Ajax Control Toolkit controls, becuase it does not inherit AjaxControlToolkit.ExtenderControlBase (server side) nor inherit AjaxControlToolkit.BehaviorBase (client side).

    So you can't use $find javascript method to get access to the behavior instance on the client, It inherits AjaxControlToolkit.ScriptControlBase (server side) and Sys.UI.Control (client side).

    To get access to control instance on the client, you use the control property on the DOM element it self as follows: < script type="text/javascript"> //considering the editor is loaded. var editorControl = $get("<%=editor.ClientID%>").control;

    //1. For setting content: editorContorl.set_content("Sample Content");

    //2. For getting content: var content = editorContorl.get_content();    < /script>

    Tuesday, April 21, 2015 8:33 AM