[CLOSED] HTMLEditor and print, copy and email functions

  1. #1

    [CLOSED] HTMLEditor and print, copy and email functions

    Hi Team,

    We want to display HTML to user on page. Page will contain 2 controls
    1. Toolbar : It contains buttons for print, copy, email , format selector

    copy: Copy HTML. i.e if you copy and then paste in word you should get formatted data in word. It should not include html tags
    Print: Print formatted HTML
    email: open outloook and use formatted HTML as email content.

    2. htmleditor : It contains actual HTML. User can just view it.

    We are opening this page in popup window.


    we are having following problems

    1. We are not able to implement copy,print, email consistently across browsers. Some times data being copied includes html tags. Please suggest us code for these operations

    2. We don't want any editing operation. But still htmleditor toolbar is appears on window. We want to avoid it. Please refer to attachment for details

    Here is our aspx page

     
    
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wndTemplate.aspx.cs" Inherits="Yob.UI.Contact.wndTemplate" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="Coolite.Utilities" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <ext:Store ID="StoreTemplates" runat="server" AutoLoad="true">
            <Listeners>
    
               
                <Load Handler="if( this.data.length>0)cmbTemplate.setValueAndFireSelect(this.getAt(0).data.rec_id);" />
            </Listeners>
             <Proxy>
                <ext:HttpProxy Json="true" AutoDataBind="true" Method="GET" Url="DataHandler.ashx" />
            </Proxy>
            <Reader>
                <ext:JsonReader Root="Tables[0].Rows" TotalProperty="RecCount">
                    <Fields>
                        <ext:RecordField Name="rec_id" Type="String" />
                        <ext:RecordField Name="desc" Type="String" />
                         <ext:RecordField Name="type" Type="String" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <ext:ScriptContainer ID="ScriptContainer1" runat="server">
        </ext:ScriptContainer>
        <title></title>
        
        <script type="text/javascript" language="javascript" >
    
    
    
            
            
    </script>
        
        <link href="../Common/Css/Style.css" rel="stylesheet" type="text/css" />
    </head>
    <body Style="height:100%;width:100%;padding:20 20 0 0 px;">
         <form id="form1" runat="server">
         <ext:ScriptManager ID="ScriptManager1" runat="server" />
        <div >
            <ext:ViewPort ID="ViewPort2" runat="server" AutoHeight="true" >
                <Body>
                    <ext:BorderLayout ID="BorderLayout2" runat="server"   >
                        <North >
                            <ext:Toolbar ID="tlbNews" runat="server" AutoWidth="true" >
                                <Items>
                                    <ext:ToolbarButton ID="tlbtnPrint" runat="server" IconCls="ToolbarItem_Report">
                                        <Listeners>
                                            <Click Handler="GetPrintData();" />
                                        </Listeners>
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip1" runat="server" Html="Print Ctrl+P" />
                                        </ToolTips>
                                    </ext:ToolbarButton>
                                    <ext:ToolbarButton ID="tlbtnCopy" runat="server" Text="" IconCls="ToolbarItem_Copy">
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip3" runat="server" Html="Copy to clipboard Ctrl+C" />
                                        </ToolTips>
                                       <Listeners>
                                            <Click Handler="CopyToClipBoard();" />
                                        </Listeners>
                                   
                                    </ext:ToolbarButton>
                                    <ext:ToolbarButton ID="tlbtnEmail" runat="server" IconCls="ToolbarItem_Email">
                                        <Listeners>
                                            <Click Handler="openEmail();" />
                                        </Listeners>
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip4" runat="server" Html="email Ctrl+M" />
                                        </ToolTips>
                                    </ext:ToolbarButton>
                                    <ext:ComboBox ID="cmbTemplate" StoreID="StoreTemplates" Hidden="false" Width="200"
                                            FieldLabel="Bankaccounts" runat="server" AutoDataBind="true" Mode="Local" DisplayField="desc"
                                            ValueField="rec_id">
                                            
                                            <AjaxEvents>
                                            <Select  OnEvent="Filltemplate" ></Select>
                                            </AjaxEvents>
                                            
                                            
                                        </ext:ComboBox>
                                </Items>
                            </ext:Toolbar>
                        </North>
                        <Center  >
                      
                         <ext:HtmlEditor  ID="HtmlEditor1" runat="server" ReadOnly="true" EnableAlignments="false" EnableColors="false" EnableFont="false"  EnableFormat="false" EnableFontSize="false" EnableLists="false" EnableLinks="false" EnableSourceEdit="false" Hidden="false"   />
                                          
                        </Center>
                    </ext:BorderLayout>
                </Body>
            </ext:ViewPort>
        
    
        </form>
    </body>
    </html>

    Here is our C# code to fill html editor

    
     public void FillHTML(object sender, AjaxEventArgs e)
            {
                datamanager msc = new datamanager();
                //it returns html
                string templatecontents = msc.GetData(cmbTemplate.SelectedItem.Value.ToString().Trim());
    
                string  htmltext = "<html><head>";
                htmltext = htmltext + "</head><body style=\'font-family : Verdana; ; margin-left : 0; margin-top:0; padding-top : 0;\'><center><p>";
                htmltext = htmltext + templatecontents;
                htmltext = htmltext + "</center></body></html>";
                HtmlEditor1.Value = htmltext;
                
                
                
            }

    Thanks &amp; regards
    yobnet team

  2. #2

    RE: [CLOSED] HTMLEditor and print, copy and email functions

    Hi ,
    Just an update.
    we are looking for implementing copy, print, email on clientside.

    Thanks &amp; Regards
    yobnet team
  3. #3

    RE: [CLOSED] HTMLEditor and print, copy and email functions

    Hi,

    1. Hide toolbar
    Please see http://forums.ext.net/showthread.php?postid=6644.aspx


    2. I don't see your current implementation of those action. I think it is better to google that information (how to copy, email and print html string)


    What I can suggest:
    - print
    HtmlEditor1.getWin().print();

    - copy. There is no cross browser solution. Some browser has support clipboard (like IE) and some don't (but you can use special Flash object for support clipboard operations).
    Please see http://www.rahulsingla.com/blog/2010...ith-javascript
    To exclude unwanted content from html editor value please javascript regular expressions (you should search in the internet how to work with regular expressions in the javascript)

    - email. You have to use mailto to send email
    window.location = 'mailto:name@site.com'
    Please see http://www.ianr.unl.edu/internet/mailto.html
  4. #4

    RE: [CLOSED] HTMLEditor and print, copy and email functions

    Hi,

    We could implement print function working. We could get copy working for Internet explorer, Chrome and Safari. It dosen't work in Firefox

    Here is our code for copy

    
    
    
    
    if ((Ext.isIE) || (Ext.isChrome) || (Ext.isSafari))
    
    
    {
    
    
    HtmlEditor1.execCmd("selectAll", null); 
    
    
    HtmlEditor1.execCmd("copy", null); 
    
    
    HtmlEditor1.execCmd("Unselect", null);
    
    
    }
    
    
    else
    
    
    {
    
    
    myFrame = HtmlEditor1.iframe;
    
    
    myFrame.content&#100;ocument.designMode = "on";
    
    
    HtmlEditor1.execCmd("selectAll", null); 
    
    
    HtmlEditor1.execCmd("copy", null); 
    
    
    HtmlEditor1.execCmd("Unselect", null);
    
    
    myFrame = HtmlEditor1.iframe;
    
    
    myFrame.content&#100;ocument.designMode = "off";
    
    
    }


    we have also tried following for firefox but it dosen't work.

    
     myFrame = HtmlEditor1.iframe;
     myFrame.content&#100;ocument.designMode = "on";
     myFrame.content&#100;ocument.execCommand("selectAll", false, null); 
     myFrame.content&#100;ocument.execCommand("copy", false, null); 
     myFrame.content&#100;ocument.execCommand("Unselect", false, null);
     myFrame.content&#100;ocument.designMode = "off";

    Can you please help us to resolve issue for Firefox?

    Thanks &amp; Regards
    yobnet team
  5. #5

    RE: [CLOSED] HTMLEditor and print, copy and email functions

    Could you post the code required to copy from a <textarea> html element using just pure JavaScript. No extjs.

    Geoffrey McGill
    Founder
  6. #6

    RE: [CLOSED] HTMLEditor and print, copy and email functions

    Hi,

    As I mentioned in my previous post the cross browser work with clipboard can be accomplished with Flas object only (see link from my previous post)

Similar Threads

  1. [CLOSED] HtmlEditor copy issue on Chrome
    By bogc in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 28, 2011, 7:31 PM
  2. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM
  3. nullable TextField with Vtype of email
    By javadzarrin in forum 1.x Help
    Replies: 1
    Last Post: Sep 06, 2010, 7:40 PM
  4. [CLOSED] Vtype email restricting hyphen...
    By shahidmughal in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 11, 2010, 6:06 PM
  5. eMail/Calendar
    By mmiocev in forum Open Discussions
    Replies: 0
    Last Post: Dec 01, 2009, 9:24 AM

Posting Permissions