Load a template using an external event

Last post 03-20-2007, 1:15 PM by jdmaynard. 3 replies.
Sort Posts: Previous Next
  •  03-15-2007, 7:03 PM 27455

    Load a template using an external event

    I'm sure I'm not the first, but I couldn't find anything like it in the forums...
     
    I'm trying to load a content template from a pop-up screen
     
    The page with the editor looks like this - the CuteEditor is in a form called "EDITFORM":
     
    ...
       Dim editor
       Set editor = New CuteEditor
         
       editor.ID = "Description"
       editor.Text = content
       editor.FilesPath = "../CuteEditor_Files"
       editor.AutoConfigure = "Enersold"
       editor.Width = 600
       editor.EditorWysiwygModeCss = "css/CuteEditor.css"
       'editor.LoadHTML("APTemplates/amine.htm") --- (this line works, but I'm trying to replace it)
       editor.Draw()
    ...
     
     
    This is some of the code from the popup window
     
    ...
        Response.Write "    var sTLDesc = ""APTemplates/amine.htm"" " & vbCrLf 
        Response.Write "    opener.document.EDITFORM.TLCatDesc.value = sTLDesc;" & vbCrLf '--- this fills a textbox properly
        Response.Write "    opener.document.EDITFORM.Description.LoadHTML(sTLDesc);" & vbCrLf
        Response.Write "    window.close();" & vbCrLf
    ...
     
    The template doesn't get loaded, and the pop-up window won't close when the LoadHTML line is in there.
    When that line is commented out, the window closes and the expected filepath sTLDesc appears in my test textbox.
     
    And my head is getting more and more sore as I look at it.
     
    It seems sooooo close.
     
    thanks
     
    Doug
     

     
     

     
  •  03-16-2007, 1:24 PM 27467 in reply to 27455

    Re: Load a template using an external event

    Doug,
     
    It will not work.
     
    LoadHTML is an Editor server side method and it can not be called in a client side script.
     
    Can you explain your situation in more details? Maybe I have other ideas.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  03-19-2007, 11:17 PM 27520 in reply to 27467

    Re: Load a template using an external event

    Hi Adam
     
    Yes, thanks - I eventually figured that out myself.
     
    You have an insert templates button in the editor that the user can use to find a template file to load into the editor.
    It works great!
     
    But ... in my application, while the client is filling out the form where the editor resides, before he even scrolls down enough to see the CuteEditor, he makes a selection that determines (among other things) which template he ought to be seeing in the editor. I'm just trying to simplify it so the user never has to choose a template using the "insert templates" button - or indeed even see the button.
     
    Seems to me, clicking the "insert templates" button starts off as a client side event so there ought to be a way ... I'm just a few grey cells away from figuring it out.
     
    thanks
     
    Doug
     
     
     
     
  •  03-20-2007, 1:15 PM 27541 in reply to 27467

    Re: Load a template using an external event

    I solved it! Yahoo!
     
    I was trying to send you a short version of my solution, but this reply template keeps refreshing itself for some reason and I lose it all.
     
    Thanks
     
    DOug
     
     
    the solution:
    1. I figure out the template file name I need (fil) and post it to a new window (tmpl)
    Response.Write " var tmpl = ""APGetTemplate.asp?Template="".concat(fil);" & vbCrLf
    Response.Write " new_window = window.open(tmpl, """")" & vbCrLf
     
    2. I catch the file name in the header of my new page.
     
     <%
      Response.Expires = -1
      Dim path
      if Request.QueryString("Template") <> "" then
       Template = Request.QueryString("Template")
      End if
      path = "APTemplates/" & Template
     %> 
     3. My new page has an iframe called 'framepreview' and I fill it up with the desired template code
     
    <iframe id="framepreview" src="<%=path%>"></iframe>
    4. The body onload event calls the following:
     var editor=opener.obj_Description // CuteEditor instance
     var htmlcode='';
     var framepreview = document.getElementById("framepreview").contentWindow; 
     
     function do_insert()
     {
      try{
    // makes a javascript variable pointing to the contents of my iframe
       htmlcode = framepreview.document.getElementsByTagName('HTML')[0].innerHTML;
      }
      catch(er)
      {
       htmlcode = framepreview.document.body.innerHTML;
       var div=document.createElement("DIV");
       div.innerHTML=htmlcode;
       htmlcode =  div.innerText;
      }
     
     
    // stuffs the template code into the editor
      editor.PasteHTML(htmlcode);  
    // closes the pop-up window
      top.close()
      
     }
     
    If the code seems familiar, I confess I pillaged it from your 'insert_template.asp' and 'browse_template.asp' pages.
     
    Thanks for your patience, and for a great product!
     
    DOug
     
     
View as RSS news feed in XML