Support forums
in

How to manually set IMG src in custom dialog

Last post 11-29-2010, 4:50 AM by Tobster. 5 replies.
Sort Posts: Previous Next
  •  11-15-2010, 5:02 AM 65004

    How to manually set IMG src in custom dialog

    I am attempting to set the src="" property of an IMG tag from a custom tab, using the following javascript (which works with other properties):
     
    function SyncTo(element) {
            element.src = "Something.gif";
    }
     
    This currently doesn't work, presumably because it synchronises with the input control on the standard 'Image' tab afterwards and gets set again with the old property.
     
    Is there any way to set this property without getting rid of the standard 'Image' tab? Such as changing the order in which the tabs synchronise to the element?
  •  11-15-2010, 1:49 PM 65014 in reply to 65004

    Re: How to manually set IMG src in custom dialog

    Dear Tobster,
     
    Please refer to the following code:
    <%@ Page Language="C#"%>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <html>
        <head>
       <script language="JavaScript" type="text/javascript" >
           function changeImg() {
               var editor1 = document.getElementById('<%=Editor1.ClientID%>');          
               //Get the editor content
               var editdoc = editor1.GetDocument(); 
               var range = editdoc.selection.createRange();
               if (editdoc.selection.type == 'Control') {
                   if (range.length == 1) {
                       var element = range.item(0);
                       if (element.tagName == 'IMG') {
                           //please add your code here
                           alert(element.src);
                       }
                   }
               }
           }
      </script>  
     <body>
            <form id="Form1" runat="server">
       <table cellpadding="15">
        <tr>
         <td>
          <CE:Editor id="Editor1"  runat="server"></CE:Editor><br />
          &nbsp;<br/><br/>         
          <p style="width:600">   
          <INPUT type=button value="change image" onclick="changeImg()" ID="Button1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </P>
          <br>   
          &nbsp;
        </td>
        </tr>
       </table> 
      </form>
     </body>
    </html>
    Thank you for asking
    Eric@cutesoft.net
  •  11-23-2010, 9:13 PM 65141 in reply to 65004

    Re: How to manually set IMG src in custom dialog

    Hi,
     
    Please try this way :
     
    inp_src.value="url.gif"
    FireUIChanged()
     
    Regards,
    Terry
  •  11-25-2010, 3:42 AM 65160 in reply to 65014

    Re: How to manually set IMG src in custom dialog

    I need to be able to do this from the SyncTo(element) function in my custom ascx file, unfortunately this method doesn't work here.
  •  11-25-2010, 3:44 AM 65161 in reply to 65141

    Re: How to manually set IMG src in custom dialog

    If I call FireUIChanged from SyncTo(element) it causes an infinite loop and reports an out of memory javascript error.
  •  11-29-2010, 4:50 AM 65186 in reply to 65014

    Re: How to manually set IMG src in custom dialog

    I think what I need is to be able to conditionally exclude
    <add pattern="IMG" tab="IMG" text="[[Image]]" control="Tag_Image.ascx" />
    from tag.config depending on what attributes the image has. Can anyone suggest how I might achieve this?
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems