O'Reilly logo

ASP.NET 2.0: A Developer's Notebook by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Let Users Move Web Parts

Note

Let your users rearrange the positions of the Web Parts on your portal to their liking.

So far we have been discussing how to create Web Parts and how to configure them to look good and nice. But we have not really touched on the most important feature of Web Parts—that is, how to let users move the Web Parts from one zone to another.

How do I do that?

In this lab, you will learn how to use the ASP.NET 2.0 Web Parts Framework to enable users to move Web Parts directly in the web browser. First you'll add a pair of radio buttons to the page so you can turn the feature on and off, and then you'll observe the behavior of the Web Parts as you move them from one zone to another.

  1. Using the project created in the previous lab (C:\ASPNET20\chap03-Webparts), add a RadioButtonList control onto the form (see Figure 3-20) and populate it with two items: a radio button named Browse Display Mode and another one named Design Display Mode. Also, check the AutoPostBack checkbox in the RadioButtonList control Tasks menu:

    <asp:RadioButtonList ID="rblMode" runat="server" AutoPostBack="True">
        <asp:ListItem>Browse Display Mode</asp:ListItem>
        <asp:ListItem>Design Display Mode</asp:ListItem>
    </asp:RadioButtonList>
    Adding a RadioButtonList control to the form

    Figure 3-20. Adding a RadioButtonList control to the form

  2. Double-click the RadioButtonList control to switch to its code-behind page, and then enter the following code. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required