Home All Groups Group Topic Archive Search About
Author
15 Feb 2006 3:49 PM
gralet
Why the TextBox’s MaxLength property set to a positive number doesn’t work
when the TextMode property is set to Multiline? What can I do to get both
properties work?
--
__________________
Luis Graillet Ramos

Author
15 Feb 2006 4:10 PM
Phillip Williams
You probably have to manage this using a JavaScript function that is
triggered onKeyPress.  Something like this:

<script type="text/javascript">
    function CheckBoxLength(maxLen)
    {
        var txtBox = window.event.srcElement;

        if (txtBox.value.length > maxLen)
        {
            alert("MaxLength has reached");
            event.returnValue=false;
            event.cancelBubble = true;
        }
    }
</script>

<asp:TextBox ID="txtMultiLine" Runat="server" TextMode="MultiLine"
Width="400px" Rows="5" onkeypress="CheckBoxLength(80)"></asp:TextBox>
Show quoteHide quote
"gralet" wrote:

> Why the TextBox’s MaxLength property set to a positive number doesn’t work
> when the TextMode property is set to Multiline? What can I do to get both
> properties work?
> --
> __________________
> Luis Graillet Ramos
Author
15 Feb 2006 5:22 PM
Patrice
For completness this is because a multiline textbox is rendered as a
textarea tag. This HTML tag doesn't have this attribute.

This is likely usually tested client side (see the other response).

--

Show quoteHide quote
"gralet" <gra***@discussions.microsoft.com> a écrit dans le message de
news:72E96296-EBCD-450C-B7D9-8AA6B6B2F2FF@microsoft.com...
> Why the TextBox's MaxLength property set to a positive number doesn't work
> when the TextMode property is set to Multiline? What can I do to get both
> properties work?
> --
> __________________
> Luis Graillet Ramos