Problem using CE as a seperate Flash/.swf selector

Last post 12-06-2010, 11:03 AM by spencet. 4 replies.
Sort Posts: Previous Next
  •  12-02-2010, 3:36 PM 65243

    Problem using CE as a seperate Flash/.swf selector

    Having trouble with the InputURL() function. Despite trying two different methods for populating my textbox back after the .swf selection, my textbox is still not populating. I've narrowed it down to the IF condition check not working using the check Images or Media files, like on other posts I read. What else can I try?
     
    Tried the following two code snippets:
    1. function InputURL()   
    2.     {    
    3.         var editor1 = document.getElementById('CE_Editor1_ID');   
    4.         var editdoc = editor1.GetDocument();     
    5.         var imgs = editdoc.images;   
    6.         if(editor1.getHTML()!="")     
    7.         {      
    8.             var s = editor1.getHTML();   
    9.             s=s.replace(/(<object[^\>]*>[\s|\S]*?)(<embed[^\>]*?)(\ssrc=\s*)\s*("|')(.+?)\4([^>]*)(.*<\/embed>)[\s|\S]*?<\/object>/gi,"$5");   
    10.             document.getElementById("imageFld").value = s;   
    11.             editor1.ExecCommand('new');   
    12.             document.getElementById("imageFld").focus();    
    13.         }     
    14.         else  
    15.         {   
    16.             setTimeout(InputURL,500);    
    17.         }     
    18.     }
    and also this one:
     
    1. function InputURL()   
    2.     {    
    3.         var editor1 = document.getElementById('CE_Editor1_ID');   
    4.         var editdoc = editor1.GetDocument();     
    5.         var imgs = editdoc.images;   
    6.         if(imgs.length > 0)     
    7.         {      
    8.             var s = editor1.getHTML();   
    9.             s=s.replace(/(<object[^\>]*>[\s|\S]*?)(<embed[^\>]*?)(\ssrc=\s*)\s*("|')(.+?)\4([^>]*)(.*<\/embed>)[\s|\S]*?<\/object>/gi,"$5");   
    10.             document.getElementById("imageFld").value = s;   
    11.             editor1.ExecCommand('new');   
    12.             document.getElementById("imageFld").focus();    
    13.         }     
    14.         else  
    15.         {   
    16.             setTimeout(InputURL,500);    
    17.         }     
    18.     }
    and neither have worked.
     
    Thanks for you help!
     
     
  •  12-02-2010, 9:58 PM 65245 in reply to 65243

    Re: Problem using CE as a seperate Flash/.swf selector

    Hi spencet,
     
    Can you paste the complete example code here and show me the steps to reproduce your issue?
     
    I will check it and get back to you as soon as possible.
     
    Regards,
     
    Ken
  •  12-03-2010, 8:09 AM 65259 in reply to 65245

    Re: Problem using CE as a seperate Flash/.swf selector

    Sure Ken, here is the display page snippet:
     
    <asp:TextBox ID="ThumbnailTextBox" runat="server" Width="200px" MaxLength="255" />
    <input type="button" value="Flash" onclick="callInsertThumbnail()" id="ThumbnailButton" name="ImageButton" runat="server" /> <asp:RequiredFieldValidator runat="server" ID="FlashRequiredFieldValidator"  
              ControlToValidate="ThumbnailTextBox"  
              Display="Dynamic"  
              ErrorMessage="<p><b>Flash is required!</b></p>" />
    <div style="background-color: #FFFFFF>   
    <CE:Editor ID="ThumbnailEditor" runat="server" Width="1" Height="1" AutoConfigure="None"  
             ShowHtmlMode="False" ShowPreviewMode="False" EnableContextMenu="false" ShowGroupMenuImage="False"  
             ShowBottomBar="False" BackColor="White" BorderColor="White">                                       
    </CE:Editor>
    </div>
     
     and the CE/javascript handle snippet:
     
                        /* calls InsertFlash browser */
                        function callInsertThumbnail() {
                            var imageEditor = document.getElementById('CE_EditFormView_ThumbnailEditor_ID');
                            imageEditor.FocusDocument();
                            var editdoc = imageEditor.GetDocument();

                            imageEditor.ExecCommand('new');
                            imageEditor.ExecCommand('InsertFlash');

                            InputThumbnailURL();
                        }
                        /* populates Flash textbox with selected flash file */
                        function InputThumbnailURL() {                        
                            var flashEditor = document.getElementById('CE_EditFormView_ThumbnailEditor_ID');
                            var editdoc = flashEditor.GetDocument();
                            var imgs = editdoc.images;

                            if (imgs.length > 0) {                             
                                document.getElementById("EditFormView_ThumbnailTextBox").value = imgs[imgs.length - 1].src;                            
                                imageEditor.ExecCommand('new');
                                document.getElementById("EditFormView_ThumbnailTextBox").focus();
                            } else {
                                setTimeout(InputThumbnailURL, 500);
                            }
                        }
     
    The process is, when I click the ImageButton to select my flash(.swf) file, I'm presented with the CE InsertFlash dialog, I navigate and select my flash file then click the Insert button on the dialog and it returns to the form with nothing entered into the ThumbnailTextBox. No .NET or javascript errors.
     
    Like I mentioned above, in my InputThumbnailURL() function, I've tried the IF() condition setup for inserting images and inserting media and neither has returned my file path selection back to the input box. The images condition (imgs.length > 0) always returns 0 and the media file condition(flashEditor.getHTML()!="") always returns blank even though I have my file selected.
  •  12-04-2010, 1:04 PM 65265 in reply to 65259

    Re: Problem using CE as a seperate Flash/.swf selector

    Dear spencet,
     
    Please refer to the following code:
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <%@ Page Language="C#" %>
    <html>
    <head>
        <title>ASP and ASP.NET WYSIWYG Editor - Use CuteEditor as a document selector</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="10" nowrap>
                    </td>
                    <td width="20" nowrap>
                    </td>
                    <td valign="top" width="760">
                        <b>Use CuteEditor as a document selector</b>
                        <hr>
                        This example demonstrates how to use CuteEditor as a document selector.
                        <br>
                        <br>
                        <asp:TextBox ID="imageFld" Width="300" runat="server" />
                        <input type="button" value="Pick a file" onclick="callInsertImage()" id="Change"
                            runat="server" name="Change">
                        <div>
                            <CE:Editor ID="Editor1" runat="server" Width="1" Height="1" AutoConfigure="None"
                                ShowHtmlMode="False" ShowPreviewMode="False" EnableContextMenu="false" ShowGroupMenuImage="False"
                                ShowBottomBar="False" BackColor="White" BorderColor="White">
                            </CE:Editor>
                            <br>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
         <Script Language="javascript">   
        function callInsertImage()    
        {    
                var editor1 = document.getElementById('CE_Editor1_ID');  
                editor1.FocusDocument();    
                var editdoc = editor1.GetDocument();    
                editor1.ExecCommand('new');  
                editor1.ExecCommand('InsertFlash');  
                InputURL();  
        }  
          
        function InputURL()  
        {   
            var editor1 = document.getElementById('CE_Editor1_ID');  
            var editdoc = editor1.GetDocument();    
            var imgs = editdoc.images;  
            if(editor1.getHTML()!="")    
            {     
                var s = editor1.getHTML();  
                s=s.replace(/(<object[^\>]*>[\s|\S]*?)(<embed[^\>]*?)(\ssrc=\s*)\s*("|')(.+?)\4([^>]*)(.*<\/embed>)[\s|\S]*?<\/object>/gi,"$5");  
                document.getElementById("imageFld").value = s;  
                editor1.ExecCommand('new');  
                document.getElementById("imageFld").focus();   
            }    
            else 
            {  
                setTimeout(InputURL,500);   
            }    
        }         
    </script>
    </body>
    </html>
     
    Thank you for asking
  •  12-06-2010, 11:03 AM 65296 in reply to 65265

    Re: Problem using CE as a seperate Flash/.swf selector

    Not sure what I had setup different but, redoing it using your code Eric, resolved my issue. Thank you very much!
View as RSS news feed in XML