Markup:
Code: Select all
<table cellpadding="0" cellspacing="4" >
<tr>
<th class="rowHeader">
<asp:Label ID="ShipMessageLabel" runat="server" Text="Gift Message:" SkinID="FieldHeader"></asp:Label>
<p style="font-weight: normal;">
<asp:Label ID="ShipMessageCount" runat="server" Text="255" ></asp:Label>
<asp:Label ID="ShipMessageHelp" runat="server" Text=" characters remaining" ></asp:Label>
<p>
</th>
<td>
<asp:TextBox ID="ShipMessage" runat="server" Text="" MaxLength="255"
TextMode="MultiLine" Columns="20" Rows="3"></asp:TextBox>
</td>
</tr>
</table>
Code: Select all
SetGiftMessageLength();
Code: Select all
private void SetGiftMessageLength()
{
foreach (RepeaterItem item in ShipmentList.Items)
{
if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item)
{
Control msgBox = item.FindControl("ShipMessage");
Control msgBoxLbl = item.FindControl("ShipMessageCount");
if (msgBox != null && msgBoxLbl != null)
{
PageHelper.SetMaxLengthCountDown(msgBox as TextBox, msgBoxLbl as Label);
((Label)msgBoxLbl).Text = Convert.ToString(Convert.ToInt16(((Label)msgBoxLbl).Text) - Convert.ToInt16(((TextBox)msgBox).Text.Length));
}
}
}
}
The message textbox does have onkeyup="return checkLength(this, 255, document.getElementById('ctl00_wpm_CheckoutPage_ctl01_ShipmentList_ctl00_ShipMessageCount'))" added to it. But nowhere on the page is the javascript function checkLength defined.
Since this worked on the multiple destination page, I haven't figured out why the checkLength script isn't being registered on the page. Can anyone spot my error? Thank you.