First of all create a new web project. While in design mode, expand the Visual Studio Toolbox and open its Web Parts category. It’s from here that we can start adding web part controls to our page. In ASP.NET every web parts page must contain one and only one WebPartManager control. Furthermore, in a web parts page, the WebPartManager must be the first web part control in the control hierarchy. Drag the WebPart-Manager control from your Toolbox and add it to the top of your page.
Design your page to include two zones left zone and right zone. To do this first make the body tag in your source code of the .aspx page looks like this :
Next, drag a WebPartZone control from the Toolbox into each of the HTML DIV elements that we added previously; these two zones will contain the web parts. When we’ve completed the page, you will be able to drag web parts between the two zones and have the personalization mechanism automatically keep track of which zone each web part belongs to. Now that the page has zones, we can add the web parts to it so the source code of your .aspx page looks like this :
Then Open the Standard category panel of the Toolbox and drag a calendar onto the left zone and drag a label web control onto the middle zone. Notice that when those controls are added to the zones, additional user interface (UI) elements are wrapped around them—namely, a title and a little down arrow. These UI elements are not related in any way to the underlying calendar or label controls but instead are specific to web parts and this will be the source code of your .aspx page :
Now your page is ready to test webparts on it but remains only one thing which is to use the appropriate WebParts display mode. The default display mode of the page is “Browse” mode which Displays Web Parts controls and UI elements in the normal mode in which users view a page. We need to change our page to “Design” mode to allow moving webparts between Zones. To do this we will add a dropdownlist which has two items: Browse and Design and don’t forget to set the property AutoPostBack to True. this will be the code in the SelectedIndexChanged event of the DropDownList :
Run your web page normally When the page is first displayed it will be in its default state “browse” mode. Change it to the design mode from the dropdownlist drag both web parts into the one zone Close the browser and then start the application up again. Notice that the web parts page “remembered” which zone the web parts were in. This is the result of the personalization saving the customization changes and reapplying them for us. Now you built your first webparts example. Hope this part is useful enough till now.
