Re: CuteEditor webpage integration

  •  01-18-2010, 2:41 PM

    Re: CuteEditor webpage integration

    Thank you for the response.
     
    Rite now I have a data base setup with a table called "News".  In this table I have 10 or so columns that I will eventually tie into each post.
     
    Currentely I am only concerned with the Columns "ID" and "Post". I have the "ID" Column set in SQL Server managment studio to "int" and "primary key".
     
    I would like to simply have a page displaying the CuteEditor. When the "Submit" button is pressed I would like the contents of the CuteEditor to be saved into the tables "Post" Column, with the "ID" column being automatically generated for each post.
     
    Later, i will create a page that retrieves this stored XML to be displayed as news articles.
     
    Here is a couple links so you can see that  I have the General Setup constructed. You may enter whatever you wish to see that it is working. the data being stored in this example is using the same tables and database my own application is using.
     
    Here is a link to the page which I am trying to implement the CuteEditor into.
     
    Below is the code I am currently working with, although I know it needs to be edited. I'm wondering if I even need to include an "ID" declaration, or if this field will be filled in automatically where it is set to "int" and "Primary key".
     
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Data.Sql;
    using System.Xml;
    using System.Data.SqlTypes;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;

    public partial class News_Post_News_Default : System.Web.UI.Page
    {
        void btnSave_Click(object sender, EventArgs e)
        {
            string xmlValue = Editor1.Text;
            //Get the connection string from the web.config file
            string connString = System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "Insert News(ID, Post) Values(@ID, @Post)";
                //Set value of parameters
                SqlParameter firstColParameter = cmd.Parameters.Add("@ID", SqlDbType.Int);
                firstColParameter.Value = ID;
                SqlParameter secondColParameter = cmd.Parameters.Add("@Post", SqlDbType.Xml);
                secondColParameter.Value = new SqlXml(new XmlTextReader(xmlValue, XmlNodeType.Document, null));
                //Execute update and close connection
                cmd.ExecuteNonQuery();
            }
            Response.Write("Saved values successfully");
        }
    }

     
     
     
View Complete Thread