Vanou’s Blog

How to use AssetUrlSelector.ClientCallback

Posted on: March 25, 2014

Lets say you want to select a picture from you SP site using AssetUrlSelector object, and assign this new image to an existing asp image object

This is when you use the ClientCallback property

 private string GetReturnScript()
        {
            string script = string.Empty;

            script = "function(newAssetUrl, newAssetText, configObject, returnValue)";
            script += "{";
            script += string.Format("document.getElementById('{0}').src=newAssetUrl;", ImageContactPictureEdit.ClientID);
            script += "}";
            return script;
        }

Assign this function to your AssetUrl control like this:

AssetUrlSelectorContactPictureEdit.ClientCallback = GetReturnScript();

When the dialog closes, the image will be displayed on your page

Leave a comment