Kentico CMS Code Snippet Library - what additional snippets do you want?
As I start to get ready for my the upcoming Kentico Connections conference I was looking at the various code and samples that I have been collecting over the last year. It made me realize that there was a lot of code! One of my favorite features in Visual Studio is Code Snippets.
I decided to start a Kentico CMS Code Snippet Library. I want to use it as a way of distributing my snippets and hopefully get feedback from people on what they would like to see. For the start I have included five code snippets
1. Get the users current site
2. Get the users information
3. Add a web part container
4. Add a CMS Repeater
5. Add a new user
What other ones would you like to see?
How do I use it?
The library is available here for download. I am using the community content installation (.vsi). This should make installation and sharing a lot easier.
1. Download the Kentico_Snippet.vsi file onto your local machine and double click it
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image001.aspx?width=624&height=25)
2. Make sure the snippet files are selected and then click Next as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image002.aspx?width=293&height=263)
3. You will receive a signature error that you need to select Yes as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image003.aspx?width=262&height=130)
Note: I will get this signed
4. Select the locations for the snippets on your machine and then select Next. You can do this for each snippet.
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image004.aspx?width=269&height=244)
Note: there are two types of snippets included -HTML and C#
5. Select Finish to copy the files on your machine
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image005.aspx?width=349&height=316)
6. Complete the installation as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image006.aspx?width=349&height=315)
With the installation complete. Open your Web project and you can use the snippets with the following steps
C# Code Snippet
1. Open the code behind of a page and right click and select Insert Snippet as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image007.aspx?width=177&height=219)
2. Select the snippet as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image008.aspx?width=464&height=131)
3. The snippet is added as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image009.aspx?width=569&height=154)
HTML Code Snippet -
1. Open the HTML of a page as shown below and right click and select Insert Snippet as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image010.aspx?width=600&height=143)
2. Select the HTML Snippet as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image011.aspx?width=609&height=88)
3. The snippet is added as shown below
![](http://devnet.kentico.com//Articles/files/Thomas-Robbins/Snippets/installation/image012.aspx?width=624&height=108)