Share via


AssetUrlSelector.GetClientLaunchPickerReference Method

Generates a client ECMAScript (JavaScript, JScript) string that opens 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 As String
'Usage
Dim instance As AssetUrlSelector
Dim returnValue As String

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

Return Value

Type: System.String
A client ECMAScript (JavaScript, JScript) string that opens the Asset Picker dialog box with the configuration specified by the properties of this control.

Exceptions

Exception Condition
NullReferenceException

A a null reference (Nothing in Visual Basic) reference exception is thrown if the Page and ID properties of this control are not set to a valid System.Web.UI.Page object for registering the required ECMAScript. Either add the control into a control collection on the page or directly set the Page and ID properties.

Remarks

The current value passed to the Asset Asset Picker dialog box is determined from the AssetUrl property value or the AssetUrlClientID property value You can use this method if the Asset Picker dialog box is opened from an HTML element other than the provided button. You can set properties on this control, and the Visible, AssetPickerButtonVisible(), or AssetUrlTextBoxVisible() properties can be set to false. You can use the ECMAScript string returned from this function in an HTML element client onclick function or an emitted ECMAScript block to oopen the Asset Picker dialog box.

The GetClientLaunchPickerReference method must be called before or during the OnPreRender phase of the page life cycle and you must set properties before calling this method to register the correct client ECMAScript on the page. Any changes to the control's properties after the call to the GetClientLaunchPickerReference method do not affect the Asset Picker dialog box behavior because the client script controlling the dialog box is already registered on the page.

Examples

    // Setting the Page and ID properties is required when the// AssetUrlSelector control is not added to the page// control tree because// the AssetUrlSelector.GetClientLaunchPickerReference()// method must register script in the page.assetSelector.Page = containerControl.Page;assetSelector.ID = "SampleGenerateAssetUrlSelectorLaunchScript";
// Uses text box client ID to connect the Asset// Picker to the text boxes for the resulting//  URL and default text values returned from the// Asset Picker dialog box.assetSelector.AssetUrlClientID = assetUrlControl.ClientID;assetSelector.AssetTextClientID = assetTextControl.ClientID;
// Set the ECMAScript 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 ECMAScript
// that in this sample is always 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 ECMAScript on the page.return clientLaunchPickerScript;
' Setting the Page and ID properties is required when the
' AssetUrlSelector control is not added to the page
' control tree because
' the AssetUrlSelector.GetClientLaunchPickerReference()
' method must register script in the page.
assetSelector.Page = containerControl.Page
assetSelector.ID = "SampleGenerateAssetUrlSelectorLaunchScript"

' Uses text box client ID to connect the Asset
' Picker to the text boxes for the resulting
'  URL and default text values returned from the
' Asset Picker dialog box.
assetSelector.AssetUrlClientID = assetUrlControl.ClientID
assetSelector.AssetTextClientID = assetTextControl.ClientID

' Set the ECMAScript to perform after populating the text boxes with the returned values.
assetSelector.ClientCallback = ScriptClientCallback


Dim clientLaunchPickerScript As String
If launchPickerWithCurrentBrowserUrl Then' Use a client launch script that calculates' the current asset URL with custom ECMAScript' that in this sample is always 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 AssetUrlClientIDclientLaunchPickerScript = assetSelector.GetClientLaunchPickerReference()
End If

' 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 ECMAScript on the page.
Return clientLaunchPickerScript

See Also

Reference

AssetUrlSelector Class

AssetUrlSelector Members

GetClientLaunchPickerReference Overload

Microsoft.SharePoint.Publishing.WebControls Namespace

AssetTextClientID

AutoPostBack

ClientCallback

AssetUrlSelector