Customise maxlength error message for different editors

Last post 03-22-2011, 4:41 PM by Eric. 1 replies.
Sort Posts: Previous Next
  •  03-22-2011, 9:48 AM 66798

    Customise maxlength error message for different editors

      Hi, 
     
    I have a page with multiple editors with different maxlengths.
     
    How can I customise the error message  that pops up so that it tells the user which editor(s) are over their character limit.
     
    At the moment I just get a generic message popping up with no reference to what editor it is associated with. 
     
    Thanks
  •  03-22-2011, 4:41 PM 66802 in reply to 66798

    Re: Customise maxlength error message for different editors

    Dear casso,
     
    If you set MaxHTMLLength, all editors will return same error message, if you want to have different error message, you need have some customization, you can refer to the following snippet:
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <%@ Page language="c#" %>
    <html>
    <head>
    </head>
    <body>
        <form runat="server" id="Form1">
            <div class="demo">        
                <CE:Editor id="Editor1" Height="200" OnPostBackCommand="Editor1_PostBackCommand"
                    ThemeType="OfficeXP" AutoConfigure="Minimal" runat="server">
                </CE:Editor><br />
                <CE:Editor id="Editor2" Height="200" runat="server" ThemeType="OfficeXP" AutoConfigure="Minimal">
                </CE:Editor>
        </form>
    </body>
    </html>
    <script runat="server">
     void Page_Load(object sender, System.EventArgs e)
      {
       
      }
     private void Editor1_PostBackCommand(object sender, System.Web.UI.WebControls.CommandEventArgs e)
     {
            if(string.Compare(((CuteEditor.Editor)sender).ClientID,"ce_editor1_id",true)==0)
            {
              string text = Editor1.PlainText;
              if (text.Length > 10)
              {
                  string myScript = "alert('You are using editor1 and you input  "+text+";You can not input more than 20 characters');";
                  Page.ClientScript.RegisterStartupScript(this.GetType(),
                  "MyScript", myScript, true);
              }
            }  
     }
    </script>
    Thank you for asking
    Eric@cutesoft.net


     

View as RSS news feed in XML