(I'm going to assume that the VBScript code you posted is client-side code. This isn't such a good idea if you hope to run this web application on any browser other then internet explorer.)
The problem is that the the html running in the client's browser doesn't know (or care) that the html was created using .NET. So it has to follow the rules of basic html and javascript. Names of controls need to be unique to be useful. So it has to prefix the textbox and other controls names with the instance name of the control they reside in.
You can try something like this:
First you need to ensure that your multiline text box (txtAltText) and the count label (fldLengthAltText) are server controls (the label will render as a <span>).
Then you assign the clientside event call on the textbox from the server-side code so you can pass to the call the fully qualified names of the objects involved:
[Server side code]
txtAltText.Attributes("onKeyUp") = String.Format("CountAndLimitAltText({0}, {1});", fldLengthAltText.ClientID, txtAltText.Client)
Now we just need to modify the client side method to deal with those arguments:
[Client side code]
sub CountAndLimitAltText(label, textbox)
label.innerhtml=len(textbox.value)
End Sub
You may have to fiddle with the clientside code to get it to work, but this is the basic idea.
-
Peter