<%@ Page Language="VB" AutoEventWireup="false" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit.HTMLEditor" tagprefix="cc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<cc2:Editor ID="myEditor" runat="server"Height="400px" />
<asp:Button runat="server" Text="Submit content" ID="submit" />
<br />
<br />
<span>
HTML:<input type="text" readonly="readonly" id="totalHtml" value=""/>
Text:<input type="text" readonly="readonly" id="totalPlain" value=""/>
</span>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
<script type="text/javascript">
Sys.Application.add_load(function() {
var editor = $find("<%= myEditor.ClientID %>");
var editPanel = editor.get_editPanel();
var designPanel = editPanel.get_modePanels()[AjaxControlToolkit.HTMLEditor.ActiveModeType.Design];
editPanel._setActive_saved = editPanel._setActive;
editPanel._setActive = function() {
if (this.get_activeMode() == AjaxControlToolkit.HTMLEditor.ActiveModeType.Design) {
var designPanel = this.get_activePanel();
designPanel.onContentChanged();
}
this._setActive_saved();
};
designPanel.onContentChanged = function() {
var innerText;
if (AjaxControlToolkit.HTMLEditor.isIE) {
innerText = this._doc.body.innerText;
} else {
var div1 = document.createElement("div");
var html = new AjaxControlToolkit.HTMLEditor.jsDocument(true);
AjaxControlToolkit.HTMLEditor.__MozillaGetInnerText(div1, html);
innerText = html.toString();
delete div1;
delete html;
}
var htmlTextLength = AjaxControlToolkit.HTMLEditor.Trim(this._doc.body.innerHTML).length;
var plainTextLength = innerText.replace(/^[\s]+/g, "").replace(/[\s]+$/g, "").replace(/[\s]+/g, " ").length;
document.getElementById("totalHtml").value = htmlTextLength;
document.getElementById("totalPlain").value = plainTextLength;
}
});
</script>
</html>
Don't forget to mark this post as answer, if it helped you...
Thanks
Happy Coding...