AssetUrlSelector.GetClientLaunchPickerReference Method (String)

Generates a client JavaScript string used to open the Asset Picker dialog box with the configuration specified by the properties of this control.

Namespace:  Microsoft.SharePoint.Publishing.WebControls
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
Public Function GetClientLaunchPickerReference ( _
    currentAssetUrl As String _
) As String
'Usage
Dim instance As AssetUrlSelector
Dim currentAssetUrl As String
Dim returnValue As String

returnValue = instance.GetClientLaunchPickerReference(currentAssetUrl)
public string GetClientLaunchPickerReference(
    string currentAssetUrl
)

Parameters

  • currentAssetUrl
    Type: System.String
    Client JavaScript string that evaluates a string value to be passed to the Asset Picker dialog box as the current value.

Return Value

Type: System.String
A client JavaScript string used to launch the Asset Picker dialog box with the configuration specified by the properties of this control.

Exceptions

Exception Condition
NullReferenceException

A nullreference exception is thrown if the Page property of this control is not set to a valid System.Web.UI.Page object to register the required JavaScript. Either add the control to a control collection on the page or directly set the Page property.

Remarks

The currentAssetUrl JavaScript parameter determines the current value passed to the Asset Picker dialog box. You can use this method if the Asset Picker dialog box is launched from an HTML element other than the button provided. You can set properties on this control and the Visible, AssetPickerButtonVisible, and **[P:Microsoft.SharePoint.Publishing.WebControls.AssetUrlSelector.]**AssetUrlTextBoxVisible properties to false. You can use the JavaScript string returned from this function in an HTML element client onclick function or an emitted JavaScript block to launch the Asset Picker dialog box. You must call the GetClientLaunchPickerReferencemethod during or before the OnPreRender phase of the page life cycle and you must set properties before calling this method in order for the page to register the correct client JavaScript. Any changes to the control's properties after the call to GetClientLaunchPickerReference do not affect the dialog box behavior because the client script controlling the dialog box is already registered in the page.

Examples

            // Set the JavaScript to perform after populating the text boxes with the returned values
            assetSelector.ClientCallback = ScriptClientCallback;

            string clientLaunchPickerScript;
            if(launchPickerWithCurrentBrowserUrl)
            {
                // Use a client launch script that calculates
                // the current asset url with custom javascript
                // which in this example always is the current browser location URL
                clientLaunchPickerScript = assetSelector.GetClientLaunchPickerReference(ScriptGetAssetUrlValue);
            }
            else
            {
                // Use the default client launch script that gets the
                // current asset URL value based on the AssetUrlClientID
                clientLaunchPickerScript = assetSelector.GetClientLaunchPickerReference();
            }

            // Add the client launch script as an ondoubleclick handler for the two text boxes
            assetUrlControl.Attributes["ondblclick"] = clientLaunchPickerScript + "; return false;";
            assetTextControl.Attributes["ondblclick"] = clientLaunchPickerScript + "; return false;";

            // Return the client launch script which can be added to other javascript on the page
            return clientLaunchPickerScript;

See Also

Reference

AssetUrlSelector Class

AssetUrlSelector Members

GetClientLaunchPickerReference Overload

Microsoft.SharePoint.Publishing.WebControls Namespace

AssetUrl

AssetUrlClientID

AssetTextClientID

AutoPostBack

ClientCallback

AssetUrlSelector