We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Rich Text Editor

How do we pass the data that is typed in to go to a sql db?

Also, is it possible to display data and edit it on the fly essentially. 

So, if I type in something like this

"Welcome to this site"

it stays there

then, later, I add on 

"Thanks for visiting"

and it would reach

"Welcome to this stie

Thanks for visiting"

5 Replies

KR Keerthana Rajendran Syncfusion Team December 11, 2018 03:27 PM UTC

Hi Bill, 
 
Thank you for contacting Syncfusion Support. 
 
We have prepared a sample by showing data from DB in RTE For sample. You can edit this text and post back value to Controller through form submit. You can save this in database or any file based on your requirement. Please refer to the below given code 
 
@model WebApplication1.Controllers.DataModel; 
 
<form asp-controller="Home" asp-action="Index" method="post"> 
    <div class="row"> 
        <div class="col-12 col-lg-10 offset-1"> 
            <ej-rte ej-for="RTEvalue" name="RTEvalue" id="input" width="820px"></ej-rte> 
        </div> 
    </div> 
    <div class="row"> 
        <div class="col-12 col-lg-10 offset-1"> 
            <button type="submit" class="btn btn-sm btn-primary mt-1">Button_Save</button> 
        </div> 
    </div> 
</form> 
 
 
DataModel model = new DataModel(); 
        public IActionResult Index() 
        { 
            List<Tables> data = new List<Tables>(); 
            string connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\WebApplication1-2055850166\WebApplication1\WebApplication1\Data\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30"; 
            SqlCommand sqlCommand = new SqlCommand(); 
            SqlConnection sqlc = new SqlConnection(connectionString); 
            SqlCommand cmd = new SqlCommand(); 
            using (sqlc) 
            { 
                sqlc.Open(); 
                SqlDataReader myReader = null; 
                SqlCommand myCommand = new SqlCommand("select * From [Table]", 
                                                         sqlc); 
                myReader = myCommand.ExecuteReader(); 
                while (myReader.Read()) 
                { 
 
                    data.Add(new Tables((byte[])myReader["byte"])); 
                    model.RTEvalue= (myReader["value"].ToString()); 
                } 
                sqlc.Close(); 
 
            } 
            
            return View(model); 
 
        } 
        [HttpPost] 
        public ActionResult Index(DataModel data) 
        { 
            string value = data.RTEvalue; 
             
            //do the action here. 
 
            return View(); 
        } 
 
 
Data can be received in controller as shown below 
 
 
 
We have attached a sample for your reference which can be downloaded from the below link 
 
 
Regards, 
Keerthana. 



BF Bill Faries December 11, 2018 04:30 PM UTC

I get the following parser error when using 

       <ej:RTE ID="input" ej-for="RTEvalue" name="RTEvalue" AutoHeight="true" Width="100%" runat="server"></ej:RTE>


Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Type 'Syncfusion.JavaScript.Web.RTE' does not have a public property named 'ej-for'.


any suggestions on that?


BF Bill Faries December 11, 2018 06:32 PM UTC

Also, the sql string connection, I put this in 
  string connectionString = @"Data Source=vmvisionsql02;Initial Catalog=Intranet;Integrated Security=True;Integrated Security=True;Connect Timeout=30";

but the other thing is that the DataModel part pretty much just comes up all red



Attachment: zip1_1b9118e7.zip


BF Bill Faries December 11, 2018 10:00 PM UTC

Basically, we want to accomplish this. 

If we can get this going, we will deff purchase a license because your products are great. 

We want to do a sql server DB      and have that text box store data and also edit on the fly   

then, we want to have files for each of the corresponding areas in their own file explorerers  

if you would like to do a call or something, let me know. 


PO Prince Oliver Syncfusion Team December 12, 2018 10:12 AM UTC

Hi Bill, 
 
Thank you for your update.  
 
Query 1: I get the following parser error when using <ej:RTE ID="input" ej-for="RTEvalue" name="RTEvalue" AutoHeight="true" Width="100%" runat="server"></ej:RTE>. Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.Parser Error Message: Type 'Syncfusion.JavaScript.Web.RTE' does not have a public property named 'ej-for' any suggestions on that? 
 
Based on the platform chosen in this ticket, we have provided sample in ASP.NET Core platform with “ej-for” RTE. It seems that, you are using ASP.NET WebForms. So, you get this error while integrating the provided code in web forms.  
 
Query 2: Also, the sql string connection, I put this in string connectionString = @"Data Source=vmvisionsql02;Initial Catalog=Intranet;Integrated Security=True;Integrated Security=True;Connect Timeout=30";but the other thing is that the DataModel part pretty much just comes up all red 
 
DataModel and Tables are model classes from which data is bound to the RTE. You get this error because the model classes are not defined in your end. Also, based on the error image we suspect that SQL namespaces reference are missing.  
 
Query 3: We want to do a sql server DB  and have that text box store data and also edit on the fly then, we want to have files for each of the corresponding areas in their own file explorers   
 
Please ignore our code and sample shared in previous update which was provided for ASP.NET Core platform. We have prepared a sample in ASP.NET WebForms based on your requirement. During initial rendering , RTE will be rendered with a default value from DB. After editing , the edited value will be updated to DB and will be maintained in RTE also. Kindly refer to the following code snipet. 
 
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
 
    <ej:RTE ID="RTESite" runat="server" Width="700px" AllowEditing="true">                                         
    </ej:RTE>    
 
    <asp:Button ID="submit" runat="server"  Text="Submit" OnClick="submit_Click" /> 
 
</asp:Content> 
 
protected void Page_Load(object sender, EventArgs e) 
        { 
            if (IsPostBack != true) 
            { 
                string rootpath = HttpContext.Current.Server.MapPath("~/App_Data/NORTHWND.MDF"); 
                string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + rootpath + ";Integrated Security=True;Connect Timeout=30"; 
                SqlConnection con = new SqlConnection(constr); 
                con.Open(); 
                SqlDataAdapter adpt = new SqlDataAdapter("select * from RTE", con); 
                DataTable dt = new DataTable(); 
                adpt.Fill(dt); 
                List<String> RteValue = new List<String>(); 
                RteValue = dt.AsEnumerable() 
                            .Select(r => r.Field<string>("value")) 
                            .ToList(); 
                RTESite.Value = RteValue[0];//set value for RTE from DB. 
            } 
        } 
 
        protected void submit_Click(object sender, EventArgs e) 
        { 
            string rootpath = HttpContext.Current.Server.MapPath("~/App_Data/NORTHWND.MDF"); 
            string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + rootpath + ";Integrated Security=True;Connect Timeout=30"; 
            SqlConnection con = new SqlConnection(constr); 
            SqlCommand cmd = new SqlCommand("SELECT * FROM RTE WHERE Id = 1 UPDATE RTE SET value = @value", con); 
            con.Open(); 
 
            cmd.Parameters.AddWithValue("@value", RTESite.Value);  //update value of RTE to DB. 
 
            cmd.ExecuteNonQuery(); 
 
            con.Close(); 
        } 
 
We have attached a sample for your reference, please find the sample at the following location: 
 
Please check the above the solution and let us know the result. Based on your result we will decide the further course of action. 
 
Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon