Creating a New SharePoint List Item with Content Type ‘Link to Document’ Item Programmatically

By: Shaili Modi

A link to a document item would create a link to any document in a sharepoint document library. It can also be used to link to documents outside of sharepoint, but we will concentrate on how to add documents from a sharepoint document library here.

A document can be made available in SharePoint with a few easy steps using the “Link To a Document” content type.

Once the ‘Link To a Document’ content type is added to the list there are two main steps:

Create an aspx file that can be used as a template to create new items

  • The Link is basically an aspx page that redirects to the document. The format of the aspx page should be as below:

  • Save it as a template.txt and use it to replace the redirect URL when creating the Link to Document item.
  • The IconOverlay Tag creates a Word like Icon instead of an aspx link icon on the item

Use the Files.Add() function to add the aspx page to the library

Once the aspx text file is ready this is how you can create a new item:

Comments are closed.