Re: Maxlength property NOT working for a multiline textbox in an UserControl

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sujith (sv12611_at_-NOSPAM-yahoo.com)
Date: 06/11/04


Date: Fri, 11 Jun 2004 10:50:35 -0700

Hi Peter...

Thanks a lot for the help.
I did make use of the code snippet in my usercontrol.
I am yet facing a strange problem out here.
The TargetObject returns a nul.
The error message is "document.forms.0.myForm1.tbxNotesToVendor is null or not an object".
I am attaching the ascx HTML file for ur reference.

Regards,
Sujith

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="OrderEntryDetails.ascx.cs" Inherits="Adecco.Commerce.Controls.OrderEntryDetails" targetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

<SCRIPT language="javascript">
        function CheckLength(TargetObject)
        {
                alert(TargetObject.value);
                LenString = TargetObject.value.length;
                if (LenString > 255)
                {
                        TargetObject.value = TargetObject.value.substring(0,255);
                }
        }
</SCRIPT>

<table cellSpacing="0" cols="2" cellPadding="0" width="100%">
        <tr>
                <td colSpan="2"><span id="OrderSubmissionDetailsLabel"></span></td>
        </tr>
        <tr>
                <td class="stdWarningSmall" colSpan="2"><asp:literal id="lblErrorMessage" runat="server"></asp:literal></td>
        </tr>
        <tr>
                <td colSpan="2">
                        <table class="stdCleanDataTable" cellSpacing="0" cols="3" cellPadding="4" width="100%">
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblSubmitForEmail" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxSubmitForEmail" runat="server" Width="300" OnTextChanged="OnSubmitEmailChange"></asp:textbox></td>
                                </tr>
                                <tr class="stdTextLabel">
                                        <td><asp:literal id="lblSubmitForFirstName" runat="server"></asp:literal></td>
                                        <td><asp:literal id="lblSubmitForMiddleName" runat="server"></asp:literal></td>
                                        <td><asp:literal id="lblSubmitForLastName" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td><asp:textbox id="tbxSubmitForFirstName" runat="server"></asp:textbox></td>
                                        <td><asp:textbox id="tbxSubmitForMiddleName" runat="server"></asp:textbox></td>
                                        <td><asp:textbox id="tbxSubmitForLastName" runat="server"></asp:textbox></td>
                                </tr>
                                <tr class="stdTextLabel">
                                        <td><asp:literal id="lblCostCenter" runat="server"></asp:literal></td>
                                        <td colSpan="2"><asp:literal id="lblSubmitForPhone" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td><asp:textbox id="tbxCostCenter" runat="server" OnTextChanged="OnCostCenterChange"></asp:textbox></td>
                                        <td colSpan="2"><asp:textbox id="tbxSubmitForPhone" runat="server"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblApprovalManager" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:dropdownlist id="drpApprovalManager" runat="server" Width="300"></asp:dropdownlist></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblMACNumber" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxMACNumber" runat="server" Width="300" MaxLength="49"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblShippingMethods" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:dropdownlist id="drpShippingMethods" runat="server" Width="300"></asp:dropdownlist></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblNotesToManager" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxNotesToManager" runat="server" MaxLength="255" TextMode="MultiLine" width="100%" height="75px"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblNotesToVendor" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td onkeydown="javascript:CheckLength(this)" onkeyup="javascript:CheckLength(this)" colSpan="3"><asp:textbox id="tbxNotesToVendor" runat="server" MaxLength="255" TextMode="MultiLine" width="100%" height="75px"></asp:textbox></td>
                                </tr>
                        </table>
                </td>
        </tr>
</table>
<br>
<table cellSpacing="0" cols="2" cellPadding="0" width="100%">
        <tr>
                <td><span id="DeliveryInformationLabel"></span></td>
                <td vAlign="bottom" align="right"><IMG src="Skins/SectionHide.jpg" onload="RegisterListener( this, 'shipperDetails', 'on' )" name="toggleShipping">
                </td>
        </tr>
        <tr id="shipperDetails">
                <td colSpan="2">
                        <table class="stdCleanDataTable" cellSpacing="0" cols="3" cellPadding="4" width="100%">
                                <tr class="stdTextLabel">
                                        <td><asp:literal id="lblDeliveryContactName" runat="server"></asp:literal></td>
                                        <td colSpan="2"><asp:literal id="lblDeliveryContactPhone" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td><asp:textbox id="tbxDeliveryContactName" runat="server" Width="200px"></asp:textbox></td>
                                        <td colSpan="2"><asp:textbox id="tbxDeliveryContactPhone" runat="server" Width="200px"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblDeliveryAddressName" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxDeliveryAddressName" runat="server" Width="200px"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblDeliveryAddressLine1" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxDeliveryAddressLine1" runat="server" Width="200px"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblDeliveryAddressLine2" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxDeliveryAddressLine2" runat="server" Width="200px"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblDeliveryAddressLine3" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxDeliveryAddressLine3" runat="server" Width="200px"></asp:textbox></td>
                                </tr>
                                <tr class="stdTextLabel">
                                        <td><asp:literal id="lblDeliveryCity" runat="server"></asp:literal></td>
                                        <td><asp:literal id="lblDeliveryState" runat="server"></asp:literal></td>
                                        <td><asp:literal id="lblDeliveryZipcode" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td><asp:textbox id="tbxDeliveryCity" runat="server" Width="200px"></asp:textbox></td>
                                        <td><asp:textbox id="tbxDeliveryState" runat="server" Width="50px"></asp:textbox></td>
                                        <td><asp:textbox id="tbxDeliveryZipcode" runat="server" Width="100px"></asp:textbox></td>
                                </tr>
                                <tr>
                                        <td class="stdTextLabel" colSpan="3"><asp:literal id="lblDeliveryCountry" runat="server"></asp:literal></td>
                                </tr>
                                <tr>
                                        <td colSpan="3"><asp:textbox id="tbxDeliveryCountry" runat="server" Width="50px"></asp:textbox></td>
                                </tr>
                        </table>
                </td>
        </tr>
</table>
<br>
<br>

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/


Relevant Pages

  • RE: Losing the arrow on a combo box.
    ... with your code snippet I have reproduced out your problem on my side. ... In Form1's InitializeComponent method, we will see the code statement order ... first>> statement, it constructs the usercontrol, which invokes ... while the ComboBox has Width of 142. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Very strange problem using FWRITE() to write data to a binary file
    ... I'm facing a very very strange problem with a very very simple C ... My goal should be to write to a binary file some numbers, ... If I execute this code (compile with Visual Studio 6) and then open the ...
    (comp.lang.c)
  • OpenWindow.document.write problem
    ... i am facing a strange problem. ... the following code is working perfectly fine in Mozilla Firefox but in ... Internet Explorer it is giving an error in the first ...
    (comp.lang.javascript)
  • ie freez
    ... I am facing a strange problem when trying to access any web-site using ... internet explorer. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Apache problem
    ... I am facing a strange problem ...on my web server if I type ... To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list ...
    (Fedora)