Re: two issues...... if any one has any ideas please help

  •  08-31-2004, 11:08 AM

    Re: two issues...... if any one has any ideas please help

    Andy,
     
    There are two ways to set a limit to the characters.
     
    1. Client side check
     
      

    <script language="JavaScript" type="text/javascript" >


    var EditorID = "youreditorID_editBox";

    var editor = document.getElementById(EditorID);

    function
    checklength()

        if (editor.innerText.length>=1000)

        {

            editor.innerText = String (editor.innerText).substring(0,1000);

        }

    }

    editor.onkeypress = checklength;

    </script>

    This way a user cannot type more then 1000 characters

     
    2. Server side check
     
      

     

    <script runat="server">

    public void Submit(object sender, System.EventArgs e)

    {

        string plaintext = Editor1.PlainText;

        if(plaintext.Length > 1000)

            Literal1.Text = "<hr><h2>The maximum length is 1000, Please try again </h2><br>";

        else

        {

            Literal1.Text += Server.HtmlEncode(Editor1.XHTML);

            ' Write the content into your database
            ....

        }

    }

    </script>

     

    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

View Complete Thread