tags:

views:

594

answers:

3

Im creating a new content type in sharepoint.

I am trying to add a new column/field that will let the user browse for an "asset" eg picture or video that exists in the sharepoint site.

how do i add a column that gives the user the ability to browse.

thanks

+3  A: 

You will want to create a custom field and provide your own browse UI in the rendering control template (see below). Its fairly straightforward to get started, but you need to be aware that there are multiple moving parts:

  1. The field type/rendering control - this is an object that encapsulates the field definition. It is responsible for understanding how to render the field at design time (when its added to a list), at run time (when its being filled out in a form, or viewed on a list view page) and the type of value the field contains.
  2. The run-time UI/rendering control template (optional) - this is the UI that is displayed when your field is collecting new values from a user on the new/edit item page.
  3. The field value class (optional) - this is how you will store the value that the user enters into the field
  4. The design time UI/editing control (optional) - this is the UI that a user will see when they add the custom field to a list

This is all described in the link above. There are many blog posts on creating custom fields.

Jason
+3  A: 

As other answers state, you should create a custom field for this functionality. However, instead of implementing the Browse functionality yourself, you should take a look at the AssetUrlSelector control found in the Microsoft.SharePoint.Publishing.WebControls namespace (you can have a look at the control using the .NET Reflector tool).

When implementing the custom field, you could add the AssetUrlSelector to the custom UserControl and making it visible when the filed is in editing mode. Below is shown an example of the approach:

<%@ Control Language="C#" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="publishing" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<SharePoint:RenderingTemplate ID="CustomFieldControl" runat="server">
  <Template>
    <publishing:AssetUrlSelector id="CustomUrlSelector" runat="server" />
  </Template>
</SharePoint:RenderingTemplate>

The example above only shows how to add the control to the custom field. Make sure that you hide the AssetUrlSelector control when not in editing mode.

Thomas Favrbo
A: 

I used PublishingWebControls:AssetUrlSelector

raklos