Simple SharePoint 2010 Replaceable Parameters with Mavention Replaceable Parameters Snippets


The new Visual Studio 2010 SharePoint Developer Tools ship with Replaceable Parameters which allow you to provide values for SharePoint solution items whose actual values are not known at the design time. And while the Replaceable Parameters are without a doubt a great improvement in the development process, there is one problem with them: there are quite a few of them and looking up the right one might get you out of element when developing. And this is exactly where Mavention Replaceable Parameters Snippets come in.

Mavention Replaceable Parameters Snippets is a collection of Visual Studio Code Snippets that contain every Replaceable Parameter available out of the box. After the installation they allow you to quickly choose the right token from a list:

Inserting a Replaceable Parameter using Mavention Replaceable Parameters Snippets

Before you start

Before you install the Mavention Replaceable Parameters Snippets you have to create a folder where you will install the snippets. In fact you will need two folders: one for snippets that can be used in all XML files, like Element Manifests and Web Parts and one for HTML snippets that can be used in ASPX pages and User Controls (ASCX).

To create the folders start up Visual Studio 2010, and choose Tools > Code Snippets Manager from the menu:

Code Snippets Manager menu option highlighted in Visual Studio 2010

In the Language box choose HTML and click the Add button. In the Select Folder dialog create new folder called HTML and inside it create another folder called SharePoint 2010. Click the Select button: the newly created SharePoint 2010 folder should appear in the tree view:

SharePoint2010 folder in the list of locations that contain HTML Code Snippets

Next you have to do the same for the XML snippets:

SharePoint 2010 folder in the list of locations that contain XML Code Snippets

Now you’re ready to install the Mavention Replaceable Parameters Snippets. Double click the .vsi file. On the first page of the wizard click the Next > button.

Visual Studio Content Installer first page of the wizard

When prompted about no signature, ignore the warning by clicking the Yes button.

No signature warning while installing the Mavention Replaceable Parameters Snippets

Next select all snippets and then select the SharePoint2010 folder in the Location window:

Selecting the location where the HTML snippets will be installed

Next do the same for the XML snippets. If you don’t uncheck the My Xml Snippets folder under Microsoft Visual Studio Tools for Applications 2005 the Mavention Replaceable Parameters Snippets will be copied to two folders.

Selecting the location where the XML snippets will be installed

Once you’re ready click the Finish button to start the installation process.

Starting the installation process

Once finished, close the wizard and start Visual Studio. Open one of your SharePoint projects, open an SPI such as Web Part and try to insert one of the Replaceable Parameters. You can do this by either selecting Edit > IntelliSense > Insert Snippet… from the menu, selecting Insert Snippet… from the context menu or pressing CTRL+K, CTRL+X on the keyboard. In the list of available snippets you should be seeing SharePoint2010:

Inserting Replaceable Parameters using Mavention Replaceable Parameters Snippets in a .webpart file

And that’s all! With Mavention Replaceable Parameters Snippet you will never have to think twice again about what the exact name of that token was.

Download: Mavention Replaceable Parameters Snippets (VSI, 19,3KB)

Important After downloading the file verify if its extension is .vsi. Depending on your browser it might get changed to .zip. In that case rename the file and change its extension to .vsi to be able to install the Code Snippets automatically.

Technorati Tags: SharePoint 2010,Visual Studio 2010

Others found also helpful: