다음을 통해 공유


AssetUrlSelector.GetClientLaunchPickerReference Method (String)

Generates a client ECMAScript (JavaScript, JScript) 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 ECMAScript (JavaScript, JScript) 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 ECMAScript (JavaScript, JScript) string used to open 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 property of this control is not set to a valid System.Web.UI.Page object to register the required ECMAScript (JavaScript, JScript). Either add the control to a control collection on the page or directly set the Page property.

Remarks

The currentAssetUrlECMAScript (JavaScript, JScript) parameter determines the current value passed to the Asset Picker dialog box. You can use this method if the Asset Picker dialog box is opened from an HTML element other than the button provided. You can set properties on this control and the Visible, AssetPickerButtonVisible, and AssetUrlTextBoxVisible properties to false. You can use the ECMAScript string returned from this function in an HTML element client onclick function or an emitted ECMAScript (JavaScript, JScript) block to open the Asset Picker dialog box. You must call the GetClientLaunchPickerReference method during or before the OnPreRender phase of the page life cycle and you must set properties before calling this method for the page to register the correct client ECMAScript (JavaScript, JScript). 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 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
// 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 ECMAScript on the pagereturn clientLaunchPickerScript;
' 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' 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()
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

AssetUrl

AssetUrlClientID

AssetTextClientID

AutoPostBack

ClientCallback

AssetUrlSelector