London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

EPi.CreateDialog returns object instead of value

Vote:
 

In our custom property we use the FileManagerBrowser.aspx in a dialog to retreive the path to the selected image.

Here is the code:

function OpenFileDialogLink(url, pageId, parentPageId, folderId, selectedfile, tbClientID) {
    url += '?id=' + pageId + '&parent=' + parentPageId + '&folderid=' + folderId;
    url += '&browserselectionmode=image&selectedfile=' + selectedfile;
    var linkAttributes = new Object();
    var dialogArguments = linkAttributes;
    var features = { width: 600 };
    var callbackArguments = new Object();
    callbackArguments.myControlId = tbClientID;
    /* opens the filemanagerbrowser dialog */
    EPi.CreateDialog(url, OnDialogClosed, callbackArguments, dialogArguments, features);
    return false;
}
function OnDialogClosed(returnValue, callbackArguments) {
    if (returnValue != undefined && returnValue != 0) {
        var myCtrl = document.getElementById(callbackArguments.myControlId);
        myCtrl.value = returnValue;
        SetPreviewImage(callbackArguments.myControlId);
    }
}

function OpenFileDialogLink(url, pageId, parentPageId, folderId, selectedfile, tbClientID) {    url += '?id=' + pageId + '&parent=' + parentPageId + '&folderid=' + folderId;    url += '&browserselectionmode=image&selectedfile=' + selectedfile;    var linkAttributes = new Object();    var dialogArguments = linkAttributes;    var features = { width: 600 };    var callbackArguments = new Object();    callbackArguments.myControlId = tbClientID;    /* opens the filemanagerbrowser dialog */    EPi.CreateDialog(url, OnDialogClosed, callbackArguments, dialogArguments, features);    return false;}
function OnDialogClosed(returnValue, callbackArguments) {    if (returnValue != undefined && returnValue != 0) {
        var myCtrl = document.getElementById(callbackArguments.myControlId);        myCtrl.value = returnValue;        SetPreviewImage(callbackArguments.myControlId);    }}

 

Calling it with the following code:

 

btFile.OnClientClick = string.Format("return OpenFileDialogLink('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')",

                    EPiServer.UriSupport.ResolveUrlFromUIBySettings("edit/FileManagerBrowser.aspx"),

                    CurrentPage.PageLink, CurrentPage.ParentLink, pageDirName,

                    System.Web.HttpUtility.UrlEncode(tbFile.Text), tbFile.ClientID);

 

The problem is that the returnValue parameter is not the selected file's path but instead [object Object]. We are using EPiServer CMS 6. Any help would be very appreciated! 

#45224
Nov 03, 2010 8:57
Vote:
 

Hi

I should returned in a property on that object. I don't remember exaclty, but I would try returnValue.href. If that doesn't work I would add a breakpoint in FireBug and inspect the returnValue object more closely.

Regards

Per Gunsarfs
EPiServer Development Team

#45238
Nov 03, 2010 11:11
Vote:
 

Hello Jonas, 

Were you able to find a solution to the problem. Iam facing similar issues now. Since while trying to get the image url it returns an object, not sure why that is ??

 

Regards

MJ

 

 

#52602
Aug 04, 2011 15:44
Vote:
 

Hi,


I just had the exact same problem and used the developer tool in IE to find out what was going on.

Instead of this code:

function OnFileDialogClosed(returnValue, callbackArguments) {

            if (returnValue != undefined && returnValue != 0) {

                var myCtrl = document.getElementById(callbackArguments.myControlId);

                myCtrl.value = returnValue

            }

        }

 

I hade to use this to get hold of the value I wanted:

function OnFileDialogClosed(returnValue, callbackArguments) {

            if (returnValue != undefined && returnValue != 0) {

                var myCtrl = document.getElementById(callbackArguments.myControlId);

                myCtrl.value = returnValue.items[0].path

            }

        }

Don't really know the reason behind this though...

I should also add that this occurred after I upgraded a site from CMS5 R2 SP2 to CMS 6 R2.


Regards
Nicklas

#65416
Edited, Jan 29, 2013 14:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.