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.
If you have closed your Visual Studio IDE, launch it now as an administrator and open the solution file that we created in the first recipe.
EmployeeList.csand add a property called
DBConnectionStringwith attributes as follows:
Personalizable(PersonalizationScope.Shared), WebBrowsable, Category("DB Connection"), WebDisplayName...