How do I refresh the page after files have uploaded with the silverlight direct file uploader?

Lucy Hyde-Thomson asked on December 22, 2014 09:14

I am using the silverlight direct file uploader to load multiple files to a media library. However I would like to refresh the page when the files have been uploaded, but can't find the event to capture. Please could someone point me in the right direction?

The control I am using is ~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.ascx

Correct Answer

Lucy Hyde-Thomson answered on January 12, 2015 18:56

Just a quick update here. I am now successfully overriding the DFU.OnUploadCompleted event with a simple document.location.refresh(). The only thing to take care with is adding your own event handler late enough in the page/control life cycle to override the one added by the DirectFileUploader control itself.

Working like a charm atm :-)

0 votesVote for this answer Unmark Correct answer

Recent Answers

Martin Danko answered on December 30, 2014 16:05

Hello Lucy,

Could you please tell me what exact version of Kentico are you running? Because Kentico 8.1 uses a new file uploader based on HTML5 instead of the Silverlight uploader from previous versions. So the Kentico version is really important in this scenario.

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 31, 2014 02:00


Where are you using this? If you're coding it in C# then you can do a Response.Redirect(CMSContext.CurrentDocument.NodeAliasPath) That would redirect you to the same page, you may have to get the URL parameters as well if you have those.

0 votesVote for this answer Mark as a Correct answer

Lucy Hyde-Thomson answered on January 12, 2015 17:36

Hi Martin and Brenden,

Many thanks for the replies and sorry for my slow response - just getting back to this problem.

I am using Kentico CMS 7 for this project at the moment so sadly I cannot use the new HTML 5 uploader yet. I am looking forward to switching to this when we port this module to version 8.1+ though.

I am using the direct uploader in a custom modal dialogue that is part of a custom module. It is adding files just fine, but I want to reload the page when the upload completes to show the new files, so I was wanting to find an event to capture.

Kentico support have suggested using the after insert event of the MediaFileInfo object as I am adding files to the media library in this case. This will work fine for single files, but not so well with multiple file uploads I suspect.

I am currently digging in to the JavaScript of the Direct file uploader which does present a DFU object with an OnUploadCompleted event. That sounds like the ticket to me, now just to get it to work with an additional event handler...

Any thoughts on other approaches would be appreciated!

0 votesVote for this answer Mark as a Correct answer

Delford Chaffin answered on November 9, 2015 19:36

How and where exactly are you overriding DFU.OnUploadCompleted? Thanks!

0 votesVote for this answer Mark as a Correct answer

Lucy Hyde-Thomson answered on November 11, 2015 11:39

Hi Delford,

I am wrapping the Kentico control ~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.ascx in my own control. In that control I have added a public method to add in the javascript for the new DFU.OnUploadCompleted event. I then call that control's method in the containing pages's OnPreRenderComplete event.

I found that any earlier in the page/control life cycle did not override the delivered DFU.OnUploadCompleted. Hope this helps, it is working well in our module.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.