I've set up a text box and label in the following way:
<asp:TextBox ID="MyTextBox" runat="server"/>
<asp:Label ID="MyLabel" runat="server"/>
Additionally, I've created a JavaScript function like this:
function checkLength(myTextBox, myLabel)
{
myLabel.innerHTML = myTextBox.value.length + '/' + myTextBox.maxLength;
}
Lastly, in the code-behind, I've implemented the following:
TextBox1.Attributes.Add("OnKeyUp", "checkLength(MyTextBox, MyLabel);");
When checkLength()
is triggered, nothing seems to happen. It appears I may be passing MyTextBox
and MyLabel
incorrectly. How should I approach this?