Posts

Showing posts from May, 2012

Adding Properties to Visual Web Parts

Image
Visual Studio 2010 introduces a new feature called “Visual Web Parts”, which allows a developer to create a web part by using a user control as a base. SharePoint 2007 developers will find this very familiar, as they’ll see that Visual Studio 2010 simply does what we had done in the past, which is to create a web part to host the user control. So a Visual Web Part is a user control inside a web part. Let’s walk through creating a Visual Web Part and allow user customization of it. We’ll start by adding a Visual Web Part to a SharePoint project. After you add the Visual Web Part to your SharePoint project, you’ll notice Visual Studio adds many items to support the new web part. There are three main items in here of interest: HelloVisualWebPart.cs  -This is the actual web part. The class contained in this code file inherits from WebPart and overrides CreateChildControls. HelloVisualWebPartUserControl.ascx  - This is the user control that will make up the interface for the w