I'm trying to fire OnKeyUp and OnKeyDown for the following script, which is used frequently to allow the user to monitor the characters left in a textbox:
<script language="javascript" type="text/javascript">
<!-- Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // trim if length is too big
field.value = field.value.substring(0, maxlimit);
// update counter
else
cntfield.value = maxlimit - field.value.length;
}
// End -->
</script>
Typically, I would set the control (named txtControl) javascript events inside the code behind as follows (this is using a master page):
txtContent.Attributes.Add("onKeyDown", "textCounter(document.aspnetForm.ctl00_ContentPlaceHolder1_txtContent,document.aspnetForm.ctl00_ContentPlaceHolder1_curRemaining," + intMaxValue + ")");
txtContent.Attributes.Add("onKeyUp", "textCounter(document.aspnetForm.ctl00_ContentPlaceHolder1_txtContent,document.aspnetForm.ctl00_ContentPlaceHolder1_curRemaining," + intMaxValue + ")");
Trying the ClientSideTextChanged method as you suggested did not work. The script did not give any errors, but the script also did not work as it was supposed to... nothing happened when changing text in the textbox.
The HTML being created for the text box contains no javascript events, which to my knowledge is neccessary to achieve what I want:
<textarea id="ctl00_ContentPlaceHolder1_txtContent" name="ctl00_ContentPlaceHolder1_txtContent" disabled="disabled" style="padding: 0px; width:450px; height: 250px;" class="ctl00_ContentPlaceHolder1_txtContent_HtmlBox"></textarea>
I really love FTB, I appreciate you developing it and supporting it in your own time... thank you!
Ryan