locked
Fckeditor value RRS feed

  • Question

  • User-1687766116 posted

    Hi, I want :

    TextBox1.Text = FCKeditor1.Value

    But this is return text whit html tags.

    I want return the text of textbox whiteout html tags.

    Please help me.

    Saturday, September 21, 2013 2:41 PM

Answers

  • User-1716253493 posted
    Apologize, I'm away from pc right now. You can try remove htmltag using Regex.Replace. TextBox1.Text = Regex.Replace (FCKeditor1.Value, "<.*?>", string.Empty)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 22, 2013 2:41 AM
  • User2019981500 posted

    use this

    public static string StripTagsRegex(string source)
        {
    	return Regex.Replace(source, "<.*?>", string.Empty);
        }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 10:05 AM

All replies

  • User2019981500 posted

    I am sure that this editor is html based so you can't do it directly.

    In code behind use string txt=request["FCKeditor1"] in page load and then assign it to TextBox1.Text=txt;


    Regards


    Saturday, September 21, 2013 2:59 PM
  • User-691245060 posted

    But this is return text whit html tags.

    HtmlEditor is there for formatting html content...so you will be getting html tags in it....if you dont want html, try this solution - http://stackoverflow.com/questions/12895795/getting-non-html-text-from-ckeditor

    get that plain text in javascript and store it in hiddenfield, then post it to server and finally assign it to the textbox.text...

    thanks,

    Saturday, September 21, 2013 3:16 PM
  • User-1687766116 posted

    I am sure that this editor is html based so you can't do it directly.
    In code behind use string txt=request["FCKeditor1"] in page load and then assign it to TextBox1.Text=txt;
    
    
    
    Regards
    
    
    
    

    I use this code:

    Partial Class admin_ins1
        Inherits System.Web.UI.Page
        Dim t1 As String
    

    and

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
            t1 = Request("FCKeditor1")
    End Sub

    and

        Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
            TextBox10.Text = t1
        End Sub

    but when i clickon  Button6 , this is not work.





    Saturday, September 21, 2013 3:24 PM
  • User2019981500 posted

    Just use

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
            t1 = Request("FCKeditor1")
    Response.write(t1);
    Response.End
    End Sub


    and see whether it is passing value to codebehind.If Not just

    use steps from itjungle

    FCKeditor is an open source WYSIWYG text editor that is often use with CMS applications. There are two versions of FCKeditor one is in Java and the other is for the .NET framework. In this tutorial I will show you how to use FCKeditor .Net in ASP.NET 2.0.

    The first thing you need to is to download the control from source forge. Make sure you download the latest one.

    There are two files that you need to download:

    1. FCKEditor
    2. FCKeditor.Net

    After you have downloaded the two files now unzip the files and have it handy somewhere. You should have a folder fckeditor and a dll file FredCK.FCKeditorV2.dll. The DLL file can be found in the bin -> Release -> 2.0 folder. Obviously the 2.0 folder is for asp.net 2.0 and 1.1 is for asp.net 1.1.

    Now create a new web application solution and add the FredCK.FCKeditorV2.dll to your reference folder. Copy the fckeditor folder that you have unzipped previously to your website folder.

    fckeditor-folder

    After you have done all that yo can begin to use the FCKeditor control. Just place this line of code in your aspx page.

        <FCKeditorV2:FCKeditor  ID="FCKeditor1" BasePath="/fckeditor/" runat="server" Height="400px">

        </FCKeditorV2:FCKeditor>

    To get the value from the FCKeditor in the code behind file use FCKeditor1.Value property.

    Example Code:

    ASPX Page:

        1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test._Default" %>

        2 <%@ Register assembly="FredCK.FCKeditorV2" namespace="FredCK.FCKeditorV2" tagprefix="FCKeditorV2" %>

        3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

        4 

        5 <html xmlns="http://www.w3.org/1999/xhtml" >

        6 <head runat="server">

        7     <title>Untitled Page</title>

        8 </head>

        9 <body>

       10     <form id="form1" runat="server">

       11     <div>       

       12         <asp:Label ID="Label1" runat="server" Text="Page Title"></asp:Label>       

       13     </div>

       14     <br />

       15     <FCKeditorV2:FCKeditor  ID="FCKeditor1" BasePath="/fckeditor/" runat="server" Height="400px">

       16     </FCKeditorV2:FCKeditor>

       17     <br />

       18     <asp:Button ID="btnSave" runat="server" onclick="Button1_Click" Text="Save"

       19         Width="71px" />

       20     </form>

       21 </body>

       22 </html>

     

     

    Class File:


     

        4 using System.Data;

        5 using System.Linq;

        6 using System.Web;

        7 using System.Web.Security;

        8 using System.Web.UI;

        9 using System.Web.UI.HtmlControls;

       10 using System.Web.UI.WebControls;

       11 using System.Web.UI.WebControls.WebParts;

       12 using System.Xml.Linq;

       13 using System.Data.SqlClient;

       14 using System.Data.Sql;

       15 

       16 namespace Test

       17 {

       18     public partial class _Default : System.Web.UI.Page

       19     {

       20         protected void Page_Load(object sender, EventArgs e)

       21         {

       22 

       23         }

       24 

       25         protected void Button1_Click(object sender, EventArgs e)

       26         {

       27             string connStr = "Data Source=compserver;Initial Catalog=sample;User Id=sample;Password=sample";

       28             SqlConnection conn = null;

       29 

       30             try

       31             {               

       32                 string strInsert = "INSERT INTO Content(Page_Content) VALUES('{0}')";

       33 

       34                 conn = new SqlConnection(connStr);

       35                 conn.Open();

       36 

       37                 strInsert = string.Format(strInsert, FCKeditor1.Value);

       38 

       39                 SqlCommand cmd = new SqlCommand(strInsert, conn);

       40                 cmd.CommandType = CommandType.Text;

       41                 cmd.ExecuteNonQuery();               

       42             }

       43             catch (Exception ex)

       44             {

       45             }

       46             finally

       47             {

       48                 conn.Close();

       49             }

       50         }      

       51     }

       52 }

    Saturday, September 21, 2013 4:34 PM
  • User-1716253493 posted
    Try : TextBox1.Text = FCKeditor1.Text. Afaik, there's another property that you can get text only value. Apologize, I'm forget the property name.
    Saturday, September 21, 2013 9:38 PM
  • User-1687766116 posted

    This is not work

    Dear oned_gk please send me property name

    thanks

    Sunday, September 22, 2013 2:21 AM
  • User-1716253493 posted
    Apologize, I'm away from pc right now. You can try remove htmltag using Regex.Replace. TextBox1.Text = Regex.Replace (FCKeditor1.Value, "<.*?>", string.Empty)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 22, 2013 2:41 AM
  • User-1687766116 posted

    Apologize, I'm away from pc right now. You can try remove htmltag using Regex.Replace. TextBox1.Text = Regex.Replace (FCKeditor1.Value, "<.*?>", string.Empty)

    <.*?> not remove all html tags

    Sunday, September 22, 2013 8:57 AM
  • User-1687766116 posted

    I want remove tags and beween the tags

    Sunday, September 22, 2013 8:59 AM
  • User-1716253493 posted
    Try use this patern : Regex.Replace (htmlDocument, @"<[^>]*>", String.Empty);
    Sunday, September 22, 2013 9:42 AM
  • User2019981500 posted
    using System.Text.RegularExpressions; 
    
    const string HTML_PATTERN = "<.*?>";
    
    static string StripHTML (string inputString)
    
    {
    
       return Regex.Replace 
    
         (inputString, HTML_PATTERN , " ");
    
    }

    Sunday, September 22, 2013 12:16 PM
  • User-1687766116 posted

    this samples remove onmly < , >

    I want remove < , > and between of <>

    Monday, September 23, 2013 8:14 AM
  • User-1687766116 posted
    This codes only remove < and > For example in <br> result is: br I want remove all of <br> Please help me.
    Tuesday, September 24, 2013 9:59 AM
  • User2019981500 posted

    use this

    public static string StripTagsRegex(string source)
        {
    	return Regex.Replace(source, "<.*?>", string.Empty);
        }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 10:05 AM