Working on Web Parts Controls in ASP.Net

The Following Steps are used to work with the WebParts Control.

Step 1: Firstly open the Visual Studio 2010 Perform the following steps

  • Click on the New->Website->Select the asp.net WebSite.
  • Add the page and named it as webparts.aspx
  • Click on View->Visual Aids and select the ASP.Net non visual controls, margins and padding.

This helps you to see layout tags and controls that do not have a UI.

Step 2: Now move your cursor inside the div tag and add the webPartManager Control from the webparts controls.

webpart.jpg

Step 3: Now in the new line add a text Working with WebParts Control.

Step 4: Add a table from the Table menu whose row is 1 and column is 2.

Step 5: Now In the first column add the WebPartZone from the WebParts Controls.Inside this control we can add any control.

Step 6: Add the two radio button inside the WebPartControl,

  • Add the new attribute title of these radio button and give the title as Select Mca Student and Select Mba Student.
  • Give the name of radio button as Mca and Mba.

The code for this is

<asp:WebPartZone ID="WebPartZone1" runat="server" Height="69px" Width="411px">

       <ZoneTemplate>

            <asp:RadioButton ID="RadioButton1" runat="server" title="Select Mca Student"

               Text="MCA"/>

            <asp:RadioButton ID="RadioButton2" runat="server" title="Select Mba Student"

               Text="MBA"/>

       </ZoneTemplate>

</asp:WebPartZone>

Step 7: Add another WebPartZone In The Second Column,

  • Add the label control inside it
  • Give the Title as Student Content
  • Give the text as Courses.
The code for this is

<asp:WebPartZone ID="WebPartZone2" runat="server" Height="58px" Width="401px">

    <ZoneTemplate>

        <asp:Label ID="Label1" runat="server" Text="Label" title="Student Content"><h2>Courses</h2></asp:Label>

    </ZoneTemplate>

</asp:WebPartZone>

Step 8: Now Run the application by pressing F5.The output is shown as

output.jpg

Summary: This Blog is simply tells you the basic use of Webparts Controls

Ebook Download
View all
Learn
View all