<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<CE:Editor ID="editor1" runat="server">
</CE:Editor>
<input type="button" value="show html" onclick="showHTML()" /><br />
<asp:TextBox ID="t1" runat="server" TextMode="multiLine" Rows="10" Width="600"></asp:TextBox>
</form>
</body>
</html>
<script>
function showHTML()
{
var t1=document.getElementById("<%= t1.ClientID %>");
t1.innerHTML=getSelectedHTML();
}
function getSelectedHTML()
{
var rng=null,html="";
var editor1=document.getElementById("<%= editor1.ClientID %>");
// get the active editor document
var editdoc = editor1.GetDocument();
// get the active editor window
var editwin = editor1.GetWindow();
for(var i=0;i<editdoc.images.length;i++)
{
editdoc.images.item(i).removeAttribute("src_cetemp");
}
if (document.selection && document.selection.createRange)
{
rng=editdoc.selection.createRange();
if( rng.htmlText )
{
html=rng.htmlText;
}
else if(rng.length >= 1)
{
html=rng.item(0).outerHTML;
}
}
else if (window.getSelection)
{
rng=editwin.getSelection();
if (rng.rangeCount > 0 && window.XMLSerializer)
{
rng=rng.getRangeAt(0);
html=new XMLSerializer().serializeToString(rng.cloneContents());
}
}
return html.split('xmlns="http://www.w3.org/1999/xhtml"').join('');
}
</script>