CuteEditor asp.net - databound in FormView - Text property not updating

Last post 07-22-2011, 9:57 AM by ahueyevi. 5 replies.
Sort Posts: Previous Next
  •  07-21-2011, 5:23 PM 68733

    CuteEditor asp.net - databound in FormView - Text property not updating

    I am using CuteEditor 6.6.0.0 in an ASP.NET 3.5 web application.  The editor control is being used as a databound control within a FormView.
     It looks like this:
       <CE:Editor ID="contentEditor" runat="Server" Text='<%# Bind("EmailContent") %>'></CE:Editor>
     
    It is pulling the correct content into the  control when the form is being bound, but it is not always giving me the updated text back when I try to save it back to the database.  I've noticed that if I switch from 'normal' to 'html' and back, before hitting the 'save' button on my form, then it *does* work.  But otherwise it just gives me the original unedited text back in the .Text property.
     
    We are using the control successfully in other projects, but it's just not working in this one.  Any hints or tips about what I might be doing wrong here?
     
  •  07-22-2011, 6:18 AM 68764 in reply to 68733

    Re: CuteEditor asp.net - databound in FormView - Text property not updating

    Hi ahueyevi,
     
    Can you post the code of the editor page? We will check it and get back to you as soon as possible.
     
    Regards,
     
    ken
  •  07-22-2011, 8:12 AM 68771 in reply to 68764

    Re: CuteEditor asp.net - databound in FormView - Text property not updating

    The page is part of a large system, so there's going to be a lot of stuff in here that won't make much sense, but here's the aspx file:
     
    <%@ Page Language="C#" MasterPageFile="~/Admin/Includes/Admin.Master" AutoEventWireup="true" CodeBehind="Details.aspx.cs" Inherits="EVI.BullsEye.Web.Admin.Setup.SystemSettings.EmailSettings.Details" Title="Untitled Page" %>
    <%@ MasterType VirtualPath ="~/Admin/Includes/Admin.Master" %>
    <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <h4>E-mail Settings</h4>
    <asp:Literal ID="savedLiteral" runat="server" Text="Setting Saved.<br /><br />" />
    Current email template:<br />
    (select from dropdown to change e-mail template) <br />
    <asp:DropDownList ID="typeList" runat="server" DataTextField="TypeDisplay" DataValueField="ID"
        DataSource='<%# EVI.BullsEye.BLL.ClientEmail.GetByClient(this.CurrentClientID) %>' AutoPostBack="true">
    </asp:DropDownList>

    <br />
    <br />

    <asp:FormView ID="clientEmailFormView" runat="server" DataKeyNames="id" DataSourceID="clientEmailDataSource"
        OnDataBound="clientEmailFormView_DataBound" DefaultMode="Edit" OnItemUpdated="clientEmailFormView_ItemUpdated">

    <EditItemTemplate>

    <asp:HiddenField ID="typeIDHidden" runat="server" Value='<%# Bind("EmailTypeID") %>' />

    <p>
        <asp:HyperLink ID="HyperLink1" runat="Server" Text="cancel" NavigateUrl="~/Admin/Setup/SystemSettings/Default.aspx" />
        <asp:LinkButton ID="LinkButton1" runat="server" Text="save" CommandName="Update" />
    </p>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
    <hr />
    <p>
        Please specify a "From" address for this message: <asp:TextBox ID="fromTextBox" Width="300px" runat="server" Text='<%# Bind("EmailFrom") %>' />
        <asp:RegularExpressionValidator ID="fromExpressionValidator" runat="server" Display="Dynamic" EnableClientScript="False"
                ErrorMessage="E-mail is not in a valid format" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                ControlToValidate="fromTextBox">*</asp:RegularExpressionValidator><br />
        (Note: If no e-mail is specified the default e-mail "<%=EVI.BullsEye.BLL.ClientEmail.DefaultFromEmail(this.CurrentClientID) %>" will be used.)
    </p>
    <hr />
    <p>
        Subject: <asp:TextBox ID="subjectTextBox" runat="server" Text='<%# Bind("Subject") %>' Width="500px" /><br />
        (Note: If no subject is specified the default subject "<%# EVI.BullsEye.BLL.ClientEmail.GetDefaultSubject((int)Eval("EmailTypeID")) %>" will be used.)
    </p>
    <hr />
    <asp:Panel runat="server" ID="emailToPanel">
        Send e-mails to (separate addresses with semicolon, example: "email1@domain.com;email2@domain.com"): <br />
        <asp:TextBox ID="sendEmailTextBox" Text='<%# Bind("EmailTo") %>' Width="600px" runat="server"></asp:TextBox>
    </asp:Panel>
    <asp:CheckBox ID="enabledCheckBox" runat="server" Checked='<%# Bind("Enabled") %>' />
    <asp:MultiView ID="typeMultiView" runat="server">
        <asp:View ID="webView" runat="server">
            <%--Send this message to a lead when they have submitted a request.<br />--%>
            Text to be replaced by information for each <%=CurrentClientTerms.Location.ToLower() %> this lead was routed to: [dealersInfo]<br />
            Text to be replaced by information about all the categories the lead was interested in: [categoryInfo]
        </asp:View>
        <asp:View ID="uploadView" runat="server">
            Text to be replaced by information for each <%=CurrentClientTerms.Location.ToLower() %> this lead was routed to: [dealersInfo]
        </asp:View>
        <asp:View ID="welcomeView" runat="server">
            <span style="color:Gray">Send this message to a dealer when their login account has been set up.</span><br />
            Text to be replaced by dealer's username: [username]<br />
            Text to be replaced by dealer's password: [password]
        </asp:View>
        <asp:View ID="newLeadsView" runat="server">
            Text to be replaced by the lead information: [leadInfo]<br />
            Text to be replaced by the rep email address: [RepEmailAddress]<br />
            <span style="color:Gray">Send this message to a dealer when a new lead has been assigned to them.</span>
        </asp:View>
        <asp:View ID="attentionView" runat="server">
            Send this message to a dealer to remind them to follow up with their leads.<br />
            Delinquency Period: <asp:TextBox ID="delinquencyTextBox" Text='<%# Bind("DelinquencyPeriod") %>' Width="50px" runat="server"></asp:TextBox> days<br />
            <asp:RequiredFieldValidator ID="delinquencyRequiredValidator" runat="server" Display="dynamic" ControlToValidate="delinquencyTextBox"
                ErrorMessage="Delinquency Period is required." EnableClientScript="false" />
            <asp:RangeValidator ID="delinquencyRangeValidator" runat="server" MinimumValue="0" MaximumValue="32767" Type="Integer" Display="Dynamic"
                ErrorMessage="Delinquency Period must be an integer greater than or equal to 0" ControlToValidate="delinquencyTextBox"
                EnableClientScript="false">*</asp:RangeValidator>
            Text to be replaced by the deliquency period, as a number: [delinquencyPeriod]<br />
            Text to be replaced by the number of delinquent leads: [numberOfLeads]
        </asp:View>
        <asp:View ID="unassignedView" runat="server">
            Send this message to designated personnel to inform them that there are unassigned leads present within the system.<br />
            <asp:CustomValidator ID="sendEmailCustomValidator" runat="server" EnableClientScript="false" ControlToValidate="sendEmailTextBox"
                Display="Dynamic" OnServerValidate="sendEmailCustomValidator_ServerValidate" ValidateEmptyText="true">*</asp:CustomValidator>
        </asp:View>
    </asp:MultiView>

    <CE:Editor ID="contentEditor" runat="Server" Text='<%# Bind("EmailContent") %>'
        
        SkinID="ThankYou" OnLoad="contentEditor_Load"></CE:Editor>
        <%--UseRelativeLinks="false" RemoveServerNamesFromUrl="false" - replace with URLType? --%>
    <p>
        <asp:HyperLink ID="cancelHyperLink" runat="Server" Text="cancel" NavigateUrl="~/Admin/Setup/SystemSettings/Default.aspx" />
        <asp:LinkButton ID="saveButton" runat="server" Text="save" CommandName="Update" />
    </p>

    </EditItemTemplate>

    </asp:FormView>

    <asp:ObjectDataSource ID="clientEmailDataSource" runat="server" SelectMethod="GetCustom" TypeName="EVI.BullsEye.BLL.ClientEmail" OldValuesParameterFormatString="{0}"
        OnSelecting="clientEmailDataSource_Selecting" UpdateMethod="Save" OnUpdating="clientEmailDataSource_Updating" >
        <SelectParameters>
            <asp:ControlParameter ControlID="typeList" Name="id" PropertyName="SelectedValue"
                Type="Int32" />
            <asp:Parameter Name="emailFrom" Type="String" />
            <asp:Parameter Name="emailTo" Type="String" />
            <asp:Parameter Name="subject" Type="String" />
            <asp:Parameter Name="enabled" Type="Boolean" />
            <asp:Parameter Name="clientID" Type="Int32" />
            <asp:Parameter Name="emailTypeID" Type="Int32" />
            <asp:Parameter Name="delinquencyPeriod" Type="Int32" />
            <asp:Parameter Name="dateCreated" Type="DateTime" />
            <asp:Parameter Name="dateLastModified" Type="DateTime" />
            <asp:Parameter Name="dateDeleted" Type="DateTime" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="emailFrom" Type="String" />
            <asp:Parameter Name="emailTo" Type="String" />
            <asp:Parameter Name="subject" Type="String" />
            <asp:Parameter Name="emailContent" Type="String" />
            <asp:Parameter Name="enabled" Type="Boolean" />
            <asp:Parameter Name="clientID" Type="Int32" />
            <asp:Parameter Name="emailTypeID" Type="Int32" />
            <asp:Parameter Name="delinquencyPeriod" Type="Int32" />
        </UpdateParameters>
    </asp:ObjectDataSource>

    </asp:Content>

     
  •  07-22-2011, 8:14 AM 68772 in reply to 68771

    Re: CuteEditor asp.net - databound in FormView - Text property not updating

    and here's the code-behind:
     
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    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 EVI.BullsEye.BLL;
    using System.Diagnostics;

    namespace EVI.BullsEye.Web.Admin.Setup.SystemSettings.EmailSettings
    {
        public partial class Details : Admin.Page
        {
            protected int? _clientEmailID;

            protected void Page_Load(object sender, EventArgs e)
            {
              
                if (!IsPostBack)
                {
                    typeList.DataBind();
                }
                else
                {

                }
                savedLiteral.Visible = false;
            }

            protected void sendEmailCustomValidator_ServerValidate(object sender, ServerValidateEventArgs args)
            {
                CustomValidator sendEmailCustomValidator = (CustomValidator)clientEmailFormView.FindControl("sendEmailCustomValidator");

                if (args.Value.Trim().Length > 0)
                {
                    string[] toAddresses = args.Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string toAddress in toAddresses)
                    {
                        if (!Utils.IsValidEmail(toAddress))
                        {
                            args.IsValid = false;
                            sendEmailCustomValidator.ErrorMessage = "The TO e-mail(s) specified was in an invalid format.";
                            break;
                        }
                    }
                }
                else
                {
                    CheckBox enabledCheckBox = (CheckBox)clientEmailFormView.FindControl("enabledCheckBox");
                    if (enabledCheckBox.Checked)
                    {
                        args.IsValid = false;
                        sendEmailCustomValidator.ErrorMessage = "The TO e-mail(s) is required.";
                    }
                }
            }

            protected void clientEmailFormView_DataBound(object sender, EventArgs e)
            {
                SetEmailTypeUI();
               
            }

            private void SetEmailTypeUI()
            {
                ClientEmail emailSetting = (ClientEmail)clientEmailFormView.DataItem;
                MultiView typeMultiView = (MultiView)clientEmailFormView.FindControl("typeMultiView");
                CheckBox enabledCheckBox = (CheckBox)clientEmailFormView.FindControl("enabledCheckBox");
                Panel emailToPanel = (Panel)clientEmailFormView.FindControl("emailToPanel");

                string viewName = null;
                switch (emailSetting.EmailTypeID)
                {
                    case (int)ClientEmail.Type.GotNewLeads:
                        enabledCheckBox.Enabled = false;
                        enabledCheckBox.Checked = false;
                        emailToPanel.Visible = true;
                        viewName = "newLeadsView";
                        break;
                    case (int)ClientEmail.Type.LeadNeedsAttention:
                        viewName = "attentionView";
                        emailToPanel.Visible = false;
                        break;
                    case (int)ClientEmail.Type.UnAssignedExists:
                        viewName = "unassignedView";
                        emailToPanel.Visible = true;
                        break;
                    case (int)ClientEmail.Type.UploadThankYou:
                        enabledCheckBox.Visible = false;
                        viewName = "uploadView";
                        emailToPanel.Visible = false;
                        break;
                    case (int)ClientEmail.Type.WebThankYou:
                        enabledCheckBox.Visible = false;
                        viewName = "webView";
                        emailToPanel.Visible = false;
                        break;
                    case (int)ClientEmail.Type.WelcomeToSystem:
                        //enabledCheckBox.Enabled = false;
                        //enabledCheckBox.Checked = false;
                        viewName = "welcomeView";
                        emailToPanel.Visible = false;
                        break;
                }
                typeMultiView.SetActiveView((View)clientEmailFormView.FindControl(viewName));
            }

            protected void clientEmailDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
            {
                e.InputParameters["clientID"] = this.CurrentClientID;
            }

            protected void clientEmailDataSource_Updating(object sender, ObjectDataSourceMethodEventArgs e)
            {
                e.InputParameters["clientID"] = this.CurrentClientID;
                CuteEditor.Editor myEdit = (CuteEditor.Editor)clientEmailFormView.FindControl("contentEditor");
                Debug.WriteLine(myEdit.Text);
            }

            protected void clientEmailFormView_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
            {
                savedLiteral.Visible = true;
            }

            protected void contentEditor_Load(object sender, EventArgs e)
            {
                string clientImagePath = GetLocalClientResourcePath() + "/editorImages";

                if(!System.IO.Directory.Exists(clientImagePath))
                    System.IO.Directory.CreateDirectory(clientImagePath);
                ((CuteEditor.Editor)sender).SetSecurityImageGalleryPath(clientImagePath);
            }
           
        }
    }

     
  •  07-22-2011, 9:25 AM 68775 in reply to 68772

    Re: CuteEditor asp.net - databound in FormView - Text property not updating

    OK, I now have the save function working when I run this project on our staging server, which is a Win 2003 machine running (of course) IIS.  It's still not working when I use it within Visual Studio on my local machine.  This project is in VS 2008, using the integrated web server.
     
    I'm wondering if there's a a reason that it would work under IIS but not under the VS 2008 integrated web server.
     
  •  07-22-2011, 9:57 AM 68776 in reply to 68775

    Re: CuteEditor asp.net - databound in FormView - Text property not updating

    Scratch the previous message -- I was using IE 9 when running localling, and Firefox 5 when looking at our staging server.  I've done some more testing, and the problem isn't local vs staging, it's browser version.  The save function does not work in IE 9.  It works fine in Firefox 5 and Chrome 12.  Also, IE 9 in IE 8 mode seems to work OK too.  It's just IE 9.
View as RSS news feed in XML