Unable to call a parameterized javascript function on my page load
===

I have a javascript function as follows:


      function textCounter(field, rem, maxlimit) {
            if (field.value.length > maxlimit)
                field.value = field.value.substring(0, maxlimit);
            else
                rem.value = maxlimit - field.value.length;
        }


Here I am trying to set the value in a textbox(rem) on the basis of length of string in another multiline textbox (field).
On my page load I am trying to call it as shown below:

    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "testFunction", "textCounter(txtRemark," + txtRemarksRem.ClientID + ", '2000')", true);


But it does not seem to work.
What am i doing wrong here.


Issue that I am trying to solve is that onkey up and keydown attribute of multiline textbox I am able to call the function and set correct valut in counter textbox(rem) but on page load its value is again set to default.
 If there is any other solution, please suggest.

    txtRemark.Attributes.Add("onKeyUp", "textCounter(this," + txtRemarksRem.ClientID + ", '2000')");
            txtRemark.Attributes.Add("onkeydown", "textCounter(this," + txtRemarksRem.ClientID + ", '2000')");

The above code seems to work fine(setting the counter value on keyup or down.