<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager" runat="server">
        </asp:ScriptManager>
        <telerik:RadScriptBlock ID="scriptBlock" runat="server">

            <script type="text/javascript"> 
            function setIntoTextBox( selection)
            { 
                var hide= $find("<%=txtSharedContent.ClientID %>");  
                hide.set_value(selection );  
                return true;
            }

            RadEditorCommandList["SaveContent"] = function(commandName, editor, oTool)  
            {  
                var editor = $find("<%=radEditor.ClientID%>") ; 
                var selection = editor.getSelectionHtml();  
                
                if(selection)  
                {
                    //setIntoTextBox(selection);
                    editor.pasteHtml('<span style="background-color:Yellow" >' + selection + '</span>');  
                  
                    var ajaxManager = $find("<%= ajaxManager.ClientID %>");
                    ajaxManager.ajaxRequest("SaveContent");  
                } 
                else  
                {
                    alert('Please select the sentence');  
                }
            }; 
            </script>
            </telerik:RadScriptBlock>
            <telerik:RadAjaxManager ID="ajaxManager" runat="server" DefaultLoadingPanelID="ajaxLoadingPanel"
                EnableAJAX="true" OnAjaxRequest="AjaxRequest" >
                <ajaxsettings>  
                    <telerik:AjaxSetting AjaxControlID="ajaxManager">  
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="radEditor"></telerik:AjaxUpdatedControl>  
                            <telerik:AjaxUpdatedControl ControlID="txtSharedContent">  
                            </telerik:AjaxUpdatedControl>  
                        </UpdatedControls> 
                    </telerik:AjaxSetting>  
                </ajaxsettings>
            </telerik:RadAjaxManager>
            <telerik:RadTextBox ID="txtSharedContent" runat="server" />
            <telerik:RadEditor ID="radEditor" runat="server" EditModes="All" ToolbarMode="default">
            <Languages>
                <telerik:SpellCheckerLanguage Code="en-US" Title="English" />
            </Languages>
            <Tools>
                <telerik:EditorToolGroup>
                    <telerik:EditorTool Name="SaveContent" Text="Save Content" />
                </telerik:EditorToolGroup>
            </Tools>
        </telerik:RadEditor>
    </form>
</body>
</html>
