I found another way of accomplishing this.
Script
function GetKeyPressInstructions() {
var count = document.getElementById('<%=txtProgramDescrClientID%>').value;
//alert(count);
var count1 = document.getElementById('<%=lblDescriptionCountClientID%>');
if (count.value.length > 0) {
count1.innerHTML = (count.value.length);
} else {
count1.innerHTML = '';
}
}
After creating properties in the code behind and setting the values to the strings/variables.
I then use a string builder to accomplish my need. ie, to get the count and display it on a label
if I tried using :
description.Attributes.Add("OnKeyUp", "GetKeyPressInstructions");
To get the method from the js it wont find it, because of the editItemTemplate.
txtProgramDescrClientID = dgvProgram.FindControl("txtProgramDescr").ClientID;
lblDescriptionCountClientID = dgvProgram.FindControl("lblDescriptionCount").ClientID;
However;
StringBuilder str = new StringBuilder();
str.Append("{");
str.Append("var count = document.getElementById('");
str.Append(txtProgramDescrClientID);
str.Append("').value;");
str.Append("var count1 = document.getElementById('");
str.Append(lblDescriptionCountClientID);
str.Append("');");
str.Append("if (count.length > 0) { count1.innerHTML = (count.length); } else { count1.innerHTML = ''; }");
str.Append("}");
description.Attributes.Add("OnKeyUp", str.ToString());