Support forums
in

Editor sends empty string to database

Last post 09-12-2006, 12:13 PM by darling1906. 12 replies.
Sort Posts: Previous Next
  •  09-11-2006, 1:51 PM 22594

    Editor sends empty string to database

    hi i am currently working on a project that takes values from two Cuteditor boxes and inserts them into a new database row. The problem is that only one editor sends data, or none sometimes. When i checked my database for errors and I get all the data except from the editors. I am attaching code below, please help.
     
    Thanks,
    DD
     
    database
     
    CREATE TABLE [dbo].[PAGES0100] (
     [page_id] [int] NOT NULL ,
     [ver_num] [int] NOT NULL ,
     [catid] [int] NOT NULL ,
     [page_title] [varchar] (80) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [page_body] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [page_rborder] [varchar] (7999) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [page_created_by_id] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [page_created_date] [datetime] NOT NULL ,
     [page_edited] [bit] NULL ,
     [page_edited_by_id] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
     [page_edited_date] [datetime] NULL ,
     [page_reviewed] [bit] NULL ,
     [page_approved] [bit] NULL ,
     [page_approved_by_id] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
     [page_approved_date] [datetime] NULL ,
     [page_status] [int] NOT NULL ,
     [page_live] [bit] NOT NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO
     
    page markup
     

    <%@ Page language="c#" Codebehind="create_page.aspx.cs" AutoEventWireup="false" Inherits="admin.create_page" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <%@ Register TagPrefix="uc1" TagName="leftmenu" Src="leftmenu.ascx" %>
    <%@ Register TagPrefix="uc1" TagName="header" Src="header.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
     <HEAD>
      <title>create_page</title>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="C#" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
     </HEAD>
     <body leftMargin="0" topMargin="0">
      <form id="Form1" method="post" runat="server">
       <P>
        <TABLE id="Table2" cellPadding="1" border="0">
         <TR>
          <TD colSpan="2"><uc1:header id="Header1" runat="server"></uc1:header></TD>
         </TR>
         <TR>
          <TD vAlign="top"><uc1:leftmenu id="Leftmenu1" runat="server"></uc1:leftmenu></TD>
          <TD vAlign="top">
           <TABLE id="Table1" borderColor="#00542d" cellSpacing="0" cellPadding="4" width="900" align="center"
            border="1">
            <TR>
             <TD colSpan="2">&nbsp;
              <asp:label id="status" runat="server" ForeColor="#009900"></asp:label></TD>
            </TR>
            <TR>
             <TD colSpan="2"><STRONG><FONT color="#009900">Create new page :: Please enter all relative
                information in the fields below</FONT></STRONG></TD>
            </TR>
            <TR>
             <TD vAlign="top" width="15%"><STRONG><FONT color="#009900">Page Category:</FONT></STRONG></TD>
             <TD vAlign="top" width="85%"><asp:radiobuttonlist id="catid_info" runat="server" Width="256px">
               <asp:ListItem Value="0">About us</asp:ListItem>
               <asp:ListItem Value="1">Donate food</asp:ListItem>
               <asp:ListItem Value="2">Donate money</asp:ListItem>
               <asp:ListItem Value="3">Other ways to help</asp:ListItem>
               <asp:ListItem Value="4">Volunteer</asp:ListItem>
               <asp:ListItem Value="5">Fresh news</asp:ListItem>
               <asp:ListItem Value="6">Just for kids</asp:ListItem>
               <asp:ListItem Value="7">Contact</asp:ListItem>
              </asp:radiobuttonlist></TD>
            </TR>
            <TR>
             <TD width="15%"><STRONG><FONT color="#009900">Page title:</FONT></STRONG></TD>
             <TD width="85%"><asp:textbox id="pg_title_txt" runat="server" Width="520px"></asp:textbox></TD>
            </TR>
            <TR>
             <TD vAlign="top" colSpan="2">&nbsp;</TD>
            </TR>
            <TR>
             <TD colSpan="2"><STRONG><FONT color="#009900">Page body&nbsp;&nbsp;&nbsp;&nbsp; </FONT></STRONG>
             </TD>
            </TR>
            <TR>
             <TD colSpan="2"><CE:Editor id="Editor1" runat="server" Width="872px" EditorWysiwygModeCss="../style.css" Autoconfigure="Simple" RemoveTBODYTag="True"></CE:Editor></TD>
            </TR>
            <TR>
             <TD colSpan="2"></TD>
            </TR>
            <TR>
             <TD colSpan="2"><STRONG><FONT color="#009900">Page right border&nbsp;&nbsp;</FONT></STRONG></TD>
            </TR>
            <TR>
             <TD colSpan="2">
              <CE:Editor id="Editor2" runat="server" Width="872px" EditorWysiwygModeCss="../style.css" Autoconfigure="Simple" RemoveTBODYTag="True"></CE:Editor></TD>
            </TR>
            <TR>
             <TD colSpan="2"><asp:button id="submit" runat="server" Text="Create Page"></asp:button></TD>
            </TR>
           </TABLE>
          </TD>
         </TR>
        </TABLE>
       </P>
      </form>
     </body>
    </HTML>
     
    code behind
     
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Web.Security;
    using System.Data.SqlClient;
    using System.Configuration;
    using admin.Objects;
    namespace admin
    {
     /// <summary>
     /// Summary description for create_page.
     /// </summary>
     public class create_page : System.Web.UI.Page
     {
      protected System.Web.UI.WebControls.RadioButtonList catid_info;
      protected System.Web.UI.WebControls.Label status;
      protected System.Web.UI.WebControls.TextBox pg_title_txt;
      protected CuteEditor.Editor Editor1;
      protected CuteEditor.Editor Editor2;
      protected System.Web.UI.WebControls.Button submit;
     
      private void Page_Load(object sender, System.EventArgs e)
      {
      
      }
      private void submit_Click(object sender, System.EventArgs e)
      {
       string coninfo = ConfigurationSettings.AppSettings["chcmssql"].ToString();
       SqlConnection chcon = new SqlConnection(coninfo);
       //get content id for page
       int page_id = NextContentID();
       //sql command to insert new content
       SqlCommand add_page = new SqlCommand("Insert into Pages0100 (page_id, ver_num, catid, page_title, page_body, page_rborder,page_created_by_id, page_created_date, page_edited, page_edited_by_id, page_edited_date, page_reviewed, page_approved, page_approved_by_id, page_approved_date, page_status, page_live) values(@page_id, @ver_num, @catid, @page_title, @pagebody, @pagerborder, @page_created_by_id, @pcd, @pe, @peid, @ped, @pr, @pa, @paid, @pad, @page_status, @page_live)", chcon);
       add_page.Parameters.Add(new SqlParameter("@page_id", System.Data.SqlDbType.Int)); 
       add_page.Parameters.Add(new SqlParameter("@ver_num", System.Data.SqlDbType.Int));
       add_page.Parameters.Add(new SqlParameter("@catid", System.Data.SqlDbType.Int));
       add_page.Parameters.Add(new SqlParameter("@page_title", System.Data.SqlDbType.VarChar));
       add_page.Parameters.Add(new SqlParameter("@pagebody", System.Data.SqlDbType.Text));
       add_page.Parameters.Add(new SqlParameter("@pagerborder", System.Data.SqlDbType.VarChar));
       add_page.Parameters.Add(new SqlParameter("@page_created_by_id", System.Data.SqlDbType.VarChar));
       add_page.Parameters.Add(new SqlParameter("@pcd", System.Data.SqlDbType.DateTime));
       add_page.Parameters.Add(new SqlParameter("@pe", System.Data.SqlDbType.Bit));
       add_page.Parameters.Add(new SqlParameter("@peid", System.Data.SqlDbType.VarChar));
       add_page.Parameters.Add(new SqlParameter("@ped", System.Data.SqlDbType.DateTime));
       add_page.Parameters.Add(new SqlParameter("@pr", System.Data.SqlDbType.Bit));
       add_page.Parameters.Add(new SqlParameter("@pa", System.Data.SqlDbType.Bit));
       add_page.Parameters.Add(new SqlParameter("@paid", System.Data.SqlDbType.VarChar));
       add_page.Parameters.Add(new SqlParameter("@pad", System.Data.SqlDbType.DateTime));
       add_page.Parameters.Add(new SqlParameter("@page_status", System.Data.SqlDbType.Int));
       add_page.Parameters.Add(new SqlParameter("@page_live", System.Data.SqlDbType.Bit));
       add_page.Parameters["@page_id"].Value = page_id;
       add_page.Parameters["@ver_num"].Value = 1;
       add_page.Parameters["@catid"].Value = Int32.Parse(catid_info.SelectedValue.ToString());
       add_page.Parameters["@page_title"].Value = pg_title_txt.Text;
       add_page.Parameters["@pagebody"].Value = Editor1.Text;
       add_page.Parameters["@pagerborder"].Value = Editor2.Text;
       add_page.Parameters["@page_created_by_id"].Value = User.Identity.Name.ToString();
       add_page.Parameters["@pcd"].Value = DateTime.Now;
       add_page.Parameters["@pe"].Value = 0;
       add_page.Parameters["@peid"].Value = null;
       add_page.Parameters["@ped"].Value = null;
       add_page.Parameters["@pr"].Value = 0;
       add_page.Parameters["@pa"].Value = 0;
       add_page.Parameters["@paid"].Value = null;
       add_page.Parameters["@pad"].Value = null;
       add_page.Parameters["@page_status"].Value = 1;
       add_page.Parameters["@page_live"].Value = 0;
       try
       {
        chcon.Open();
        add_page.ExecuteNonQuery();
        status.Text = "Page was added to database";
       }
       catch
       {
        status.Text = "Page, could not be added, Page name already exists, or please try again";
       }
       finally
       {
        chcon.Close();
        pg_title_txt.Text = "";
        Editor2.Text= "";
        Editor1.Text= "";
        catid_info.ClearSelection();   
       }
      
      }
      private int NextContentID()
      {
       // SELECT   DISTINCT ContentID
       // FROM     Content
       // ORDER BY ContentID DESC

       string coninfo = ConfigurationSettings.AppSettings["chcmssql"].ToString();
       SqlConnection chcon = new SqlConnection(coninfo);
       SqlCommand Command = new SqlCommand("get_NextContentID", chcon);
       Command.CommandType = CommandType.StoredProcedure;
       SqlDataAdapter DAdpt = new SqlDataAdapter(Command);
       DataSet ds = new DataSet();
       DAdpt.Fill(ds, "Pages0100");
       if (ds.Tables["Pages0100"].Rows.Count <= 0)
        return 1;
       return Convert.ToInt32(ds.Tables["Pages0100"].Rows[0]["Page_id"]) + 1;
      }
      #region Web Form Designer generated code
      override protected void OnInit(EventArgs e)
      {
       //
       // CODEGEN: This call is required by the ASP.NET Web Form Designer.
       //
       InitializeComponent();
       base.OnInit(e);
      }
      
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {   
       this.submit.Click += new System.EventHandler(this.submit_Click);
       this.Load += new System.EventHandler(this.Page_Load);
      }
      #endregion
      
     }
    }
  •  09-11-2006, 2:43 PM 22596 in reply to 22594

    Re: Editor sends empty string to database

    darling1906,
     
    In this example, can you tell me which one works, which one doesn't work.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-11-2006, 2:48 PM 22597 in reply to 22594

    Re: Editor sends empty string to database

    Editor2 will output data while editor1 doesn't produce anything
  •  09-11-2006, 2:50 PM 22598 in reply to 22597

    Re: Editor sends empty string to database

    Please change
     
    add_page.Parameters["@pagebody"].Value = Editor1.Text;
    to
     
    add_page.Parameters["@pagebody"].Value = "Hello world";
     
    and try again.
     

     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-11-2006, 3:13 PM 22599 in reply to 22598

    Re: Editor sends empty string to database

    I just tried it using .Value = "text" and that writes to the database. I trited testing both editors and neither one is outputting data even adding to my finally statement
     
    Response.Write(Editor1.Text); or the same for editor2.text
     
    i get nothing returned
  •  09-11-2006, 3:51 PM 22600 in reply to 22599

    Re: Editor sends empty string to database

    Please change
     
    finally
       {
        chcon.Close();
        pg_title_txt.Text = "";
        Editor2.Text= "";
        Editor1.Text= "";
        catid_info.ClearSelection();   
       }
      
     
    to
     
    finally
       {
        chcon.Close();
        pg_title_txt.Text = "";
        catid_info.ClearSelection();   
       }
     
    and try again.
     
    Keep me posted
     

      

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-11-2006, 4:06 PM 22602 in reply to 22600

    Re: Editor sends empty string to database

    I made the changes and still nothing, is there another way to access the HTML produced? I even tried using Editor1.XHTML and I got nothing back.
     
     
  •  09-11-2006, 4:17 PM 22603 in reply to 22602

    Re: Editor sends empty string to database

    Let us change your submit_Click and see the result.
    private void submit_Click(object sender, System.EventArgs e)
     {
      status.Text = "<h2>The HTML you typed is...</h2><br>";
      status.Text += Server.HtmlEncode(Editor1.Text) + "<br><br>";
      status.Text += Server.HtmlEncode(Editor2.Text);
     }
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-11-2006, 7:28 PM 22606 in reply to 22603

    Re: Editor sends empty string to database

    I still only get output from Editor1. I wonder if there is some sort of overload taking place with both editors trying to output data??
  •  09-11-2006, 7:55 PM 22607 in reply to 22606

    Re: Editor sends empty string to database

    Darling1906,
     
    This doesn't make sense. Can you provide FTP access to this page?
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-11-2006, 8:11 PM 22608 in reply to 22607

    Re: Editor sends empty string to database

     
    user: iwebdgro_anon
    pass: cutesoft
     
    I uploaded the files there, if you need anything else please let me know. So far when I remove Editor2, Editor1 with send the data to SQL server. But with both Editors I get no data output from them.
  •  09-12-2006, 9:48 AM 22628 in reply to 22608

    Re: Editor sends empty string to database

    Please let me know if there is any update to this... thanks
  •  09-12-2006, 12:13 PM 22631 in reply to 22628

    Re: Editor sends empty string to database

    I resolved this issue. although there was nothing wrong with the code or the page markup, there seemed to be some conflict going on. I simply created a new page with the same exact code and markup and it works.. crazy.. I think there is some code being left over when you delete the editor from the page and add a new one.
     
    THanks
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems