MaxHTMLLength and UpdatePanel

Last post 04-02-2009, 8:42 AM by BobL. 3 replies.
Sort Posts: Previous Next
  •  04-01-2009, 10:29 AM 50611

    MaxHTMLLength and UpdatePanel

    Hello-
     
    I'm having an issue with the MaxHTMLLength property.  I have an updatepanel containing a CuteEditor and a submit button.  I fill up the cuteditor with enough text to overflow the limit. 
     
    When I click the submit button, I see an error message ("The HTML Code to be added has reached the chacter limit... Please reduce the length to continue"), but the data is then truncated and the postback is not stopped. 
     
    So either the error message needs to get changed to "The data will be truncated" or it needs to stop the postback from happening. Perhaps I'm missing a setting here or some way to hook up the control to a ValidationGroup to stop the postback?  The updatepanel might not have anything to do with it.
     
    Thanks,
    Bob
  •  04-01-2009, 10:33 AM 50612 in reply to 50611

    Re: MaxHTMLLength and UpdatePanel

     
    One additional thing - if it is in a gridview and I hit edit, then cancel it still displays the message during the cancel action.  It doesn't stop the cancel from happening which is good, but I wouldn't think it should validate when canceling.
  •  04-02-2009, 4:36 AM 50683 in reply to 50611

    Re: MaxHTMLLength and UpdatePanel

    Hi BobL,
     
    Please tyr this way:
     
     protected void submit_Click(object sender, EventArgs e)
        {
            if(editor1.Text.Length>5000)
            {
            //do not save
            }
        }
     
    When text more than a value, stop doing anything
     
    Regards,
     
    Ken
  •  04-02-2009, 8:42 AM 50690 in reply to 50683

    Re: MaxHTMLLength and UpdatePanel

     
    Thanks, but that's not going to work with gridviews very well and doesn't "fit" with the way ASP.NET does validation.  For what its worth, I ended up removing the MaxHTMLLength Property and implementing a customvalidator.  This works both inside and outside a gridview and can implement validationgroups.
    <script type="text/javascript">
    function CheckLength (oSrc, args) {
    args.IsValid = (args.Value.Length <= 7000);
    }
    </script>
    <asp:CustomValidator ID="custEntry" runat="server" ErrorMessage="Must be less than 7000 encoded characters - Please shorten the entry." ClientValidationFunction="CheckLength" ControlToValidate="ceEntry" ValidationGroup="grpAddEntry" ValidateEmptyText="False" Display="Dynamic" />
     
     
View as RSS news feed in XML