How to: Set the Display Mode of a Web Parts Page
The Web Parts technology provides a variety of page display modes that enable users to perform customizations on a Web page; however, it is the responsibility of the page developer to decide which display modes the end user will need and make them available. This topic shows how to create simple "design" and "browse" buttons that set theproperty of the instance. In design mode, the user can drag Web Parts controls to edit the layout of the page, whereas in browse mode only standard Web browsing functionality is available. For descriptions of the other page display modes, see .
To create the Design and Browse buttons and their Click events
Create an ASP.NET page that includes a WebPartManager control, somecontrols, and some standard Web controls inside the zones. For step-by-step assistance, see .
Create twocontrols outside the zones, one with its and properties both set to "Design" and one with both properties set to "Browse".
Place the Click event handlers for the two buttons in a
<script>block in the head of the page, or in the code page if you are using a code-behind file. Your code should look like the following example.
Protected Sub Design_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Design.Click ' Get the current WebPartManager instance. Dim mgr As WebPartManager mgr = WebPartManager.GetCurrentWebPartManager(Page) ' Set the display mode. mgr.DisplayMode = mgr.SupportedDisplayModes.Item("Design") End Sub Protected Sub Browse_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Browse.Click ' Get the current WebPartManager instance. Dim mgr As WebPartManager mgr = WebPartManager.GetCurrentWebPartManager(Page) ' Set the display mode. mgr.DisplayMode = mgr.SupportedDisplayModes.Item("Browse") End Sub
Build and run the page. When you click the Design button, you should be able to drag controls between zones; when you click Browse, drag-and-drop functionality is disabled.