Adding configuration properties to web parts

The web parts are configured by authorized users. You can use that as an opportunity and provide properties that can be set during the configuration time rather than hard coding in the code. In this recipe, we will learn how to add those configuration properties to the web parts.

In our first recipe, we had hard coded the database connection string. In this recipe, we will modify the web part to get the database connection string from the configuration property.

Getting ready

Since this recipe is a modification of the first recipe, you should complete that recipe successfully in order to follow this one.

How to do it...

  1. If you have closed your Visual Studio IDE, launch it now as an administrator and open ...

Get Microsoft SharePoint 2010 Development with Visual Studio 2010: Expert Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.