Asset Picker in SharePoint 2010

The Asset Picker tool enables authors to more easily find, sort, and view various types of assets that are available on the site. For example, you can find, view, and then insert a URL or an image from any SharePoint Server library or list in the current site collection. You can use the Asset Picker to insert content without having to type the URL that points to it. The Asset Picker is available in many field controls found on publishing sites, such as:

  • The HTML Editor field control
  • The Image field control
  • The Summary Links Web Part

The Look In pane contains shortcuts to predefined SharePoint Server libraries. These shortcuts are designed to help authors locate content quickly, without having to navigate through the folders in the site collection. In image pickers, these shortcuts point to:

  • The image library for the current site.
  • The image library for the current site collection.
  • In URL pickers, the shortcuts point to:
  • The pages library for the current site.
  • The document library for the current site.
  • The document library for the current site collection.

If your authors frequently want to insert documents that are not found in these default locations, you can define an additional shortcut pointing to another location in your site collection. You can define one custom shortcut to image pickers and one custom shortcut to URL pickers. When defined, these shortcuts appear in the Look In pane next to the default shortcuts. You can define custom picker shortcuts only in the scope of one control: After you edit the markup for a control in a template file, only Asset Pickers launched from that control display the specified custom shortcuts.

Attribute

Description

DefaultOpenLocationUrl

Sets the default location where the Asset Picker should be opened.

DefaultsToLastUsedLocation

Set to True to open the Asset Picker window in the last used location. The first time that you use the Asset Picker, it opens in the location specified by the DefaultOpenLocationUrl property.

Set to False if you always want the Asset Picker window to open in the location specified in DefaultOpenLocationUrl.

DisplayLookInSection

Set to True to display a Look In section in the Asset Picker window. Otherwise, set to False.

OverrideDialogFeatures

Overrides various properties in the Asset Picker dialog box.

OverrideDialogTitle

Sets the title of the Asset Picker dialog box.

OverrideDialogDescription

Sets the description displayed near the top of the Asset Picker dialog box.

OverrideDialogImageUrl

Sets the icon displayed in the upper-right of the Asset Picker dialog box.

AssetTextClientID

When specified, this ID is used to find the HTML element for the AssetText value returned by the Asset Picker.

Defaults to the ClientID of the child TextBox control.

AsserUrlClientID

When specified, this ID is used to find the HTML element for the AssetUrl value that the Asset Picker returns.

Defaults to the ClientID of the child TextBox control.

ClientCallback

A string containing an ECMAScript (JavaScript, JScript) function to call when the Asset Picker dialog box returns a value.

Defaults to String.Empty.

UseImageAssetPicker

Set to True to use the image version of the Asset Picker.

Set to False to use the URL version of the Asset Picker. The image picker opens by default in Thumbnail view. If a user selects a URL that does not point to an image, the application warns the user.

AllowExternalURLs

Set to True to allow external URLs to be specified.

The default is False.

AssetUrlTextBoxVisible

Set to False to hide the URL text box.

The default is True.

AssetPickerButtonVisible

Set to False to hide the button that launches the Asset Picker window.

The default is True.

AutoPostBack

Set to True to cause the Asset Picker to automatically post back when the user changes the selected URL by typing directly in the text box, or when the user selects a different item in the Asset Picker window. The default is False.

AsserUrlClientID

When specified, this ID is used to find the HTML element for the returned AssetUrl value returned by the Asset Picker.

Defaults to the ClientID of the child TextBox control.

How to implement Asset Picker

The following code will help you to implement the Asset Picker. I have started with a visual web part and added the following code:

AstPckrShr1.jpg

Once implemented deploy the web art. We will see the following the Asset Picker in action:

AstPckrShr2.jpg

You can browse the button to see the asset in your SharePoint site:

AstPckrShr3.jpg