Losing Editor content when saving

Last post 09-02-2008, 1:25 PM by ValleyHope. 3 replies.
Sort Posts: Previous Next
  •  08-12-2008, 3:45 PM 42918

    Losing Editor content when saving

    I have some weird behavior happening.  CuteEditor v6.1.0.0.  I have a page where a user will take a while to type in it, and for security purposes I can't/won't change the session expiration on my website. (By the way, this is not meant to start a security debate).
     
    I enabled a javascript timer set to go off at 10 minutes, fires up a click event on a button, and the button's click event will save the Editor.Text in the database, reloads the page, therefore renewing the session and so on.  I'm testing in all 4 "major" browsers, IE7, FF3, Safari 3.1.2(win) and Opera 9.51.
     
    Scenario 1:
     
    I type whatever on the editor and close to the 10 minute mark (actually for testing I have it set for 1 minute) before I get the popup message, I stop typing, let it sit for a few seconds, let the message popup, click on OK, let the page refresh.  When I check the database, whatever I typed, it's there.
     
    Here is the kicker -  If I continue typing for the duration of the timer (60 seconds for testing) and I'm still typing when the message pops up, click on the OK, reloads the page...  with IE7, the content is there, with the rest of the browsers I get a blank message.
     
    Scenario 2:
     
    Same setup, but with a plain 'ol <asp:textbox> as the "editor".  Both times, by stoping before the timer runs thru, or continuing to type, the data is there on all 4 browsers.
     
    So it leads me to believe it's a behavior with CuteEditor.  Any ideas?
  •  08-13-2008, 11:26 AM 42938 in reply to 42918

    Re: Losing Editor content when saving

    Can you post the code showing how you trigger this event, how you get the data from editor?

    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

  •  08-15-2008, 8:53 AM 42997 in reply to 42938

    Re: Losing Editor content when saving

    Adam,
     
    Here is the ascx:
     

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PM_Add.ascx.cs" Inherits="xxx.yyy" %>

    <asp:UpdatePanel ID="up_PMAdd" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
      <table width="100%">
       <tr>
        <td colspan="3">
         To:
         <asp:DropDownList ID="ddl_SentTo" runat="server" />
        </td>
       </tr>
       <tr>
        <td colspan="3">
         Subject:
         <asp:TextBox ID="TextBox1" runat="server" Width="300px" TabIndex="1" />
        </td>
       </tr>
       <tr>
        <td colspan="3">
         
         <VHA:Editor ID="Editor_NewPM_Counselor" runat="server" AllowPasteHtml="false" Width="100%"
          Height="250px" ConfigurationPath="~/CuteSoft_Client/CuteEditor/Configuration/AutoConfigure/VHAMinimal.config"
          ConvertHTMLTagstoLowercase="true" EditorOnPaste="Default" ShowBottomBar="false" />
        </td>
       </tr>
      </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Literal ID="lbl_AutoSave" runat="server" />
    <asp:Timer ID="Timer_PMAdd" runat="server" Interval="15000" OnTick="Timer_PMAdd_Tick" />
    <span style="visibility: hidden;">
        <asp:Button ID="Button1" runat="server" /></span>
    <VHAAjax:ModalPopupExtender ID="mpu_AutoSave" BehaviorID="mdlPopup" runat="server"
        TargetControlID="Button1" PopupControlID="pnl_AutoSave" BackgroundCssClass="modalBackground" />
    <asp:Panel ID="pnl_AutoSave" runat="server" CssClass="confirm-dialog" Style="display: none;">
        <div class="inner">
            <h5>
                You are reaching the end of your session.</h5>
            <p style="padding-right: 20px; text-align: justify;">
                In order for you to keep the data you have entered so far, it will be saved for
                you. The page will reload and you can continue typing your message.</p>
            <asp:Button ID="btn_AutoSave" runat="server" Text="Save" OnClick="btn_AutoSave_Click" />
            <p>
            </p>
        </div>
    </asp:Panel>

    And here is the codebehind
     

    using System;
    using System.Data;
    using System.Data.Sql;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Profile;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using VHA.OCC.BLL;

    namespace xxx
    {
        public partial class yyy : System.Web.UI.UserControl
        {
            string cs_Live = ConfigurationManager.ConnectionStrings["XXX"].ConnectionString;
            string AutoSave = "";

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {  
                    if (Request.QueryString["AutoSave"] != null)
                    {
                        AutoSave = Request.QueryString["AutoSave"].ToString();
                    }
                   
                    if (AutoSave == "")
                    {
                        //Do all initial display of controls
                    }
                    else
                    {
                        //Grab the data and put it in the controls ie.  Editor_PM_Add.Text = reader["xxx"];
                    }
                }
            }

            protected void Timer_PMAdd_Tick(object sender, EventArgs args)
            {
                Timer_PMAdd.Enabled = false;
                mpu_AutoSave.Show();
            }

            protected void btn_AutoSave_Click(object sender, EventArgs e)
            {
                string SID = Session.SessionID.ToString() + Session["NewLoginID"];
                string tempSubject = "";
                string tempMessage = "";
                string tempSendTo = "";

       tempSendTo = ddl_SentTo.SelectedValue.ToString();
       tempSubject = TextBox1.Text.Replace("'", "''");
       tempMessage = Editor_NewPM_Counselor.Text.Replace("'", "''");

       string aSql = "SELECT SessionID FROM XXX WHERE SessionID LIKE '" + SID + "'";

                SqlConnection aConn = new SqlConnection(cs_Live);
                aConn.Open();
                SqlCommand aComm = new SqlCommand(aSql, aConn);
                SqlDataReader a;
                a = aComm.ExecuteReader();

                if (a.Read())
                {
                    string bSql = "UPDATE XXX SET MessageContent = '" + tempMessage + "', MessageSubject = '" + tempSubject + "' WHERE SessionID LIKE '" + SID + "'";
                    SqlConnection bConn = new SqlConnection(cs_Live);
                    bConn.Open();
                    SqlCommand bComm = new SqlCommand(bSql, bConn);
                    bComm.ExecuteNonQuery();
                    bConn.Close();

                    Response.Redirect("PM_Add.aspx?AutoSave=" + DateTime.Now.ToUniversalTime() + "", true);
                }
                else
                {
                    string cSql = "INSERT INTO XXX (SessionID, MessageType, MessageContent, MessageSubject) VALUES ('" + SID + "', 'PM', '" + tempMessage + "', '" + tempSubject + "')";
                    SqlConnection cConn = new SqlConnection(cs_Live);
                    cConn.Open();
                    SqlCommand cComm = new SqlCommand(cSql, cConn);
                    cComm.ExecuteNonQuery();
                    cConn.Close();
                }
                a.Close();
                aConn.Close();

                Response.Redirect("PM_Add.aspx?AutoSave=" + DateTime.Now.ToUniversalTime() + "", true);
            }

        }
    }
     
    By the way, I'm running the latest version 6.1.2
  •  09-02-2008, 1:25 PM 43440 in reply to 42997

    Re: Losing Editor content when saving

    Any ideas?
View as RSS news feed in XML