Home Search Member List Faq Register Login  
UltimateEditor
Loading Attachments Programmatically

Thread Starter: BDrayson   Started: 01-29-2007 11:02 AM   Replies: 17
 Karamasoft Support Forums » General Discussions » UltimateEditor » Loading Attachments Programmatically
 Printable Version    « Previous Thread   Next Thread »
  29 Jan 2007, 11:02 AM
BDrayson is not online. Last active: 1/31/2007 5:22:12 AM BDrayson

Not Ranked
Joined on 01-29-2007
Posts 3
Loading Attachments Programmatically

Question regarding the ultimate editor and how attachments are added to the component.  I am building a web based email system that will use templates for the more common messages that are sent on a daily basis. 

chemas-microsoft-comSurprisefficeSurpriseffice" />> >

These templates need to include attachments, it is very easy to use the ultimate editor component to build the template and to grab the details of the attachments included in the template (by using GetAttachmentList() )  however I am having major problems if I wish to load a template and automatically set the editor control to what attachments were previously saved.  I was hopeful that there was a SetAttachementLis() method or that it would be simple to call a javascript function on the client side of the editor to update what is being held in session.  However I have not been able to do this and it is driving me mad! 

> >

I have inspected the UltimateEditor.upload.aspx and located a javascript function that I believe will help curEditorObj.ue2s(dirName, fName, fSize); but I can not get this to call or run on my main webform regardless of how I reference it, have tried EmailEditObj.ue2s(…) (EmailEditObj is the name of the component on the form) UltimateEditors.EmailEdiObj.ue2s(..) etc. 

> >

There seems to be very sparse client side documentation and the UltimateEditor.js is a joke to look at, all the code on one line and a nonsensical naming convention.

> >

If anyone has had any ideas on how to do this or even how the attachment details are stored in the session, or even how to reference the editor component from javascript I would welcome the help

> >

Regards

> >

Blake


  
  29 Jan 2007, 12:30 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically
We have not originally provided a method like SetAttachmentList because once you submit the page, you normally clear the attachments in the page so that they are not submitted again when the page is submitted the next time. To help us better understand the issue, basically, do you want to keep displaying the attachment list after the page is submitted?
  
  30 Jan 2007, 4:10 AM
BDrayson is not online. Last active: 1/31/2007 5:22:12 AM BDrayson

Not Ranked
Joined on 01-29-2007
Posts 3
Re: Loading Attachments Programmatically

This would be used to populate the attachments list on first load of the page, its being used to load predifined templates with attachments so they can be used for common emails we send to customers.


  
  30 Jan 2007, 12:44 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically
Thanks for your feedback. We will work on this issue and let you know as soon as it is ready for download.
  
  31 Jan 2007, 12:59 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically

We have not fully designed how the API should be and put this issue to our future development list. However, you can use the following workaround to set the attachments during initial page load.

Add the following client-side script block into HEAD section of your page. Basically, it should be placed before your editor server control.

<script language="javascript">
function EmailEditObj_OnLoad() {
  curEditorObj = UltimateEditors['EmailEditObj'];
  curEditorObj.ue2s('6858b88d-10a7-48e1-abb1-acb2d107973d', 'test.txt', 1024);
}
</script>

As can be seen at http://www.karamasoft.com/UltimateEditor/ClientAPI.htm, [ultimateEditorId]_OnLoad() is a function template to handle window onload events after the UltimateEditor control is completely loaded and ready to be reached by the UltimateEditors collection on the client-side.

Therefore, your client-side function name should be EmailEditObj_OnLoad since your editor control id is EmailEditObj.

Inside this function, you first set global curEditorObj variable, which is defined in UltimateEditor.js, to UltimateEditors['EmailEditObj']. Note that you don't define it with var in front of it since it is already defined.

Then, you call ue2s method, which is used to handle various functionality to add the selected file to attachment list and display it in th eeditor attachment list. You have already found out this function before.

The first parameter is file upload directory name. This directory is found under Uploads directory under UltimateEditorInclude directory. Every time a file is attached or image is inserted, a new GUID is generated and the file is stored under this new directory under Uploads directory.

The second parameter is the file name attached.

The third parameter is the size of the file in bytes.

You will probably need to generate this script block dynamically on the server-side if these three parameters are dynamic.

Let us know if you have any further questions.


  
  31 Jan 2007, 1:58 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically

We will release the new builds over the weekend. You can get the latest updates on Monday.


  
  31 Jan 2007, 5:01 AM
BDrayson is not online. Last active: 1/31/2007 5:22:12 AM BDrayson

Not Ranked
Joined on 01-29-2007
Posts 3
Re: Loading Attachments Programmatically
Fantastic, workaround provides exactly what was required. Thank you for your help and advice.
  
  27 Feb 2008, 8:06 PM
jkhsu is not online. Last active: 9/10/2010 11:24:14 AM jkhsu

Top 10 Posts
Joined on 09-14-2007
Posts 34
Re: Loading Attachments Programmatically
I'm trying to do the same thing, and I tried this workaround. However, EmailEditObj_OnLoad() is never called in my case.
I also tried to put the line "curEditorObj = UltimateEditors['EmailEditObj'];
" in my UltimateEditor1_OnLoad() function. The code is executed, but curEditorObj is undefined... Any ideas?

I'm also trying to display the attachment file names above the toolbar after postback. Is there an example I can follow?

Thanks!

  
  27 Feb 2008, 10:37 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically

As explained in ClientAPi documentation, you should use the ID of your own editor to create your own _OnLoad handler. For example, if the server-side ID of your editor is UltimateEditor1, then use the following JavaScript call:

<script language="javascript">
function <%=UltimateEditor1.ClientID%>_OnLoad() {
  curEditorObj = UltimateEditors['<%=UltimateEditor1.ClientID%>'];
  curEditorObj.ue2s('6858b88d-10a7-48e1-abb1-acb2d107973d', 'test.txt', 1024);
}
</script>

This code should render the attachment list after the page is posted back as well.

Please also note that UltimateEditor provides GetAttachmentList method on the server-side, which returns the comma delimited list of attached filenames. You can use that method on the server-side to do your custom programming to render the attachment list.


  
  29 Feb 2008, 7:48 PM
jkhsu is not online. Last active: 9/10/2010 11:24:14 AM jkhsu

Top 10 Posts
Joined on 09-14-2007
Posts 34
Re: Loading Attachments Programmatically

Is there an example on how to render the attachment list above the toolbar? Thanks!


  
  04 Mar 2008, 2:53 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically
We currently don't have any samples on how to render the attachment list after the postback, however, we added this issue to our product enhancement list so that the editor can load the attachment list after the postback automatically in the future. Thanks for your feedback.
  
  03 Jun 2008, 6:50 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically
With the release of UltimateEditor3.1, attachments are now loaded automatically after the page is posted back. Please visit the Release History page at http://www.karamasoft.com/UltimateEditor/History.aspx to see the changes and download the latest version from our website and try again.
  
  10 Jun 2008, 2:10 PM
jkhsu is not online. Last active: 9/10/2010 11:24:14 AM jkhsu

Top 10 Posts
Joined on 09-14-2007
Posts 34
Re: Loading Attachments Programmatically
I've tried the version 3.1 demo, and the attachments are kept after postback. Thank you!

However, is there a method like SetAttachmentList in the new release?

  
  11 Jun 2008, 2:40 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Loading Attachments Programmatically
There is no SetAttachmentList method. UltimateEditor now automatically displays the files attached before the postback.
  
  13 May 2011, 12:27 AM
alsig is not online. Last active: 8/26/2013 12:14:19 PM alsig

Top 10 Posts
Joined on 02-17-2011
Posts 22
Re: Loading Attachments Programmatically
I am using your method to set attachments on page load using a hidden field to hold a string of attachments in the format:
hiddenAttachment.value = file1Dir,file1Name,file1Size;file2Dir,file2Name,file2Size;...

the Javascript onLoad function is:

        function <%=UltimateEditor1.ClientID%>_OnLoad() {
            var curEditorObj = UltimateEditors['<%=UltimateEditor1.ClientID%>'];
            if (document.getElementById('<%=hiddenAttachment.ClientID%>').value != '') {
                var attachmentString = document.getElementById('<%=hiddenAttachment.ClientID%>').value;
                var attachmentFiles = attachmentString.split(";");
                for (var i = 0; i < attachmentFiles.length; i++) {
                    var attachmentParts = attachmentFiles[i].split(",");
                    curEditorObj.ue2s( attachmentParts[0], attachmentParts[1], attachmentParts[2]);
                }
                document.getElementById('<%=hiddenAttachment.ClientID%>').value = '';
            }
        }

which works just fine.  The Attachment: file names and sizes look correct, until I call the 'save' postBack.  Then the attachment list changes the file name displayed for each of my onLoad attachments to 'undefined', although when I check GetAttachmentList the file names look correct.  While the fille name says 'undefined', the size of the file remains correct when i click on "Attachments:".

Also, the was no Uploads directory under UltimateEditorInclude, so I created it.  At no time have I found a GUID folder where you say the attachments might reside.

How do I get the Attachment names to not be changed to 'undefined' after save PostBack?
Also, where are the attached files supposed to reside, since there is no GUID directory?
Thanks,
Alan S.

  
 Page 1 of 2 (18 items) 1 2 »
Karamasoft Support Forums » General Discussions » UltimateEditor » Loading Attachments Programmatically

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2019 Karamasoft LLC. All rights reserved.