Re: CuteEditor webpage integration

  •  01-24-2010, 10:04 PM

    Re: CuteEditor webpage integration

    I just wanted to update this page for anyone else whom might be having problems. I was able to get this working by switching the code back to my .aspx page from the code behind page.
     
    All I did here was paste the code from the XmlDataTypeSave.aspx howto tutorial, then edit a few various pieces that you can inspect below. This is a very simple example, and I will be incorporating many more commands to the asp "Post" button.
     
    Thank you for the help on getting this running!
     
    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Post_News.aspx.cs" Inherits="News_Post_News_Post_News" Title="Untitled Page" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.Data.Sql" %>
    <%@ Import Namespace="System.Xml" %>
    <%@ Import Namespace="System.Data.SqlTypes" %>

        

    <asp:Content ID="Content1" ContentPlaceHolderID="PortalCPH" Runat="Server">
        <script runat="server">

        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(Post) Values(@Post)";
                //Set value of parameters
                SqlParameter firstColParameter = cmd.Parameters.Add("@Post", SqlDbType.Xml);
                firstColParameter.Value = new SqlXml(new XmlTextReader(xmlValue, XmlNodeType.Document, null));
                //Execute update and close connection
                cmd.ExecuteNonQuery();         
            }
            Response.Write("Saved values successfully");
        }
    </script>

    <CE:Editor id="Editor1" runat="server" />

        <asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" Text="Post"
            Height="24px" Width="89px" />

    </asp:Content>

View Complete Thread