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">
<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"> </TD>
</TR>
<TR>
<TD colSpan="2"><STRONG><FONT color="#009900">Page body </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 </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
}
}