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

Last post 08-31-2004, 11:08 AM by Adam. 1 replies.
Sort Posts: Previous Next
  •  08-30-2004, 7:07 PM 1657

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

    Is there anyway to set a limit to how many characters are allowed from each text box....  (i dont want someone to write a 20000 word essay and mess up the SQL DB)   

     
    Secondly , does any one know of any conflicts with Infragistics controls.....
     
    Please reply
     
    Andy
  •  08-31-2004, 11:08 AM 1659 in reply to 1657

    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 as RSS news feed in XML