I'm using the Ajax HtmlEditorExtender and I need to count the characters of a textbox.
I use a javascript code to count the characters (remaining & left) and it works fine with regular textboxes in asp.net. But if i use it for a textbox that is related to HtmlEditorExtender. The Javascript code does not work-- (The function is not called).
My code looks like this:
Javascript code:
<script type="text/javascript">
function textCounter(field, countfield) {
if (field.value.length > 100)
field.value = field.value.substring(0, 100);
else
countfield.value = 100 - field.value.length;
}</script>default.aspx page:
<input readonly="readonly" type="text" id="remLen" size="3" maxlength="3" value="160" />
<asp:TextBox ID="txtSlideTexts" TextMode="MultiLine" Columns="50" Rows="8" Runat="server" /><ajaxToolkit:HtmlEditorExtender ID="hee" TargetControlID="txtSlideTexts" Runat="server" DisplaySourceTab="true"><Toolbar> <ajaxToolkit:Undo /><ajaxToolkit:Redo /><ajaxToolkit:Bold /><ajaxToolkit:Italic /><ajaxToolkit:Underline /><ajaxToolkit:UnLink /><ajaxToolkit:RemoveFormat /><ajaxToolkit:Cut /><ajaxToolkit:Copy /><ajaxToolkit:Paste /></Toolbar></ajaxToolkit:HtmlEditorExtender>
and finally the Default.aspx.cs code:
protected void Page_Load(object sender, EventArgs e)
{
txtSlideTexts.Attributes.Add("onkeyup", "return textCounter(this, remLen);");
txtSlideTexts.Attributes.Add("onkeydown", "return textCounter(this, remLen);");
}
any suggestions?