Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 6 - Using Themes and Skins for Personalization...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Using Themes and Skins for Personalization with Visual Basic 2005
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2006-12-07

    Table of Contents:
  • Using Themes and Skins for Personalization with Visual Basic 2005
  • Organize Site Themes and Skins
  • Enable Themes and Skins
  • Using Named Skins
  • Web Parts
  • Enabling Editing and Layout Changes
  • Editing a Part

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Using Themes and Skins for Personalization with Visual Basic 2005 - Enabling Editing and Layout Changes
    (Page 6 of 7 )

    Web Parts provide users with the ability to change the layout of the Web Part controls by dragging them from zone to zone. You may also allow your users to modify the appearance of the controls, their layout and their behavior.

    The built-in Web Parts control set provides basic editing of any Web Part control on the page. You can also create custom editor controls that allow users to do more extensive editing.

    Creating a User Control to Enable Changing Page Layout

    To edit the contents of zones or move controls from one zone to another, you need to be able to enter Edit and Design mode. To do so, you will create a new user control called DisplayModeMenu.ascx, that will allow the user to change modes among Browse, Edit, and Design, as shown in Figure 12-55.


    Figure 12-55.  Display Mode user control

    Right-click on the web project in the Solution explorer and choose Add New Item. Select Web User Control and name the new user controlDisplayModeMenu.

    User controls are described in detail in Chapter 13.

    Add the highlighted code listed in in Example 12-25 to the content file of your new user control.

    Example 12-25. DisplayModeMenu .ascx file

    <%@ Control Language="VB" AutoEventWireup="false"
    CodeFile="DisplayModeMenu.ascx.vb" Inherits="DisplayModeMenu" %>
    <div>
     
    <asp:Panel ID="Panel1" runat="server"
        Borderwidth="1"
        Width="230"
        BackColor="lightgray"
        Font-Names="Verdana, Arial, Sans Serif" >
        <asp:Label ID="Label1" runat="server"
          Text="&nbsp;Display Mode"
          Font-Bold="true"
          Font-Size="8"
          Width="120" />
        <asp:DropDownList ID="ddlDisplayMode" runat="server"
          AutoPostBack="true"
          EnableViewState="false"
          Width="120"
          OnSelectedIndexChanged= "ddlDisplayMode_SelectedIndexChanged" />
      </asp:Panel>
    </div>

    This code creates a panel, and within that panel it adds a single drop-down list (ddlDisplayMode). It also sets the event handler for when the Selected item changes in the drop-down list. To support this page, open the code-behind file (DisplayModeMenu. ascx.vb) and add the code shown in Example 12-26.

    Example 12-26. DisplayModeMenu.ascx.vb

    Imports System.Web.UI
    Partial Class DisplayModeMenu
        Inherits System.Web.UI.UserControl

       Dim myWebPartManager As WebPartManager

       Protected Sub Page_Init(_
       ByVal sender As Object, _
       ByVal e As System.EventArgs) Handles Me.Init
         
    AddHandler Page.InitComplete, AddressOf Page_InitComplete
       End Sub

       Protected Sub Page_InitComplete( _
       ByVal sender As Object, _
       ByVal e As System.EventArgs)

       myWebPartManager = _ 
        WebPartManager.GetCurrentWebPartManager(Page)

       For Each mode As WebPartDisplayMode In _
         myWebPartManager.SupportedDisplayModes
         Dim modeName As String = mode.Name
          If mode.IsEnabled(myWebPartManager) Then
             Dim myListItem As ListItem = _
                New ListItem(modeName, modeName)
             ddlDisplayMode.Items.Add(myListItem)
          End If
       Next
    End Sub

       Protected Sub ddlDisplayMode_SelectedIndexChanged( _
       ByVal sender As Object, _
       ByVal e As System.EventArgs) _
       Handles ddlDisplayMode.SelectedIndexChanged
          Dim selectedMode As String = ddlDisplayMode.SelectedValue
          Dim mode As WebPartDisplayMode = _ 
         myWebPartManager.SupportedDisplayModes(selectedMode)
          If (mode IsNot Nothing) Then
             myWebPartManager.DisplayMode = mode
          End If
       End Sub

       Protected Sub Page_PreRender( _
       ByVal sender As Object, _
       ByVal e As System.EventArgs) Handles Me.PreRender
         
    Dim items As ListItemCollection = ddlDisplayMode.Items
          Dim selectedIndex As Integer = _
          items.IndexOf(items.FindByText(myWebPartManager.DisplayMode.Name))
          ddlDisplayMode.SelectedIndex = selectedIndex
      
    End Sub
    End Class

    Open theWebPartsDemopage in Design mode and make a space between theWebPartManagerand the table of zones. Drag the DisplayModeMenu.ascx file from the Solution explorer into that space. Change to Source view and notice that Visual Studio 2005 has done two things for you: it has registered the new control:

      <%@ Register Src="DisplayModeMenu.ascx" TagName="DisplayModeMenul"
      TagPrefix="uc1" %>

    and it has placed the control into the form:

      <div>
          <asp:WebPartManager ID="WebPartManager1" runat="server" />
        <uc1:DisplayModeMenul ID="DisplayModeMenul1" runat="server" />

    Before testing this, delete the Web Part Zone in the lower righthand cell in the table and drag an Editor Zone into that cell. Drag an AppearanceEditorPart and a LayoutEditorPart onto the Editor Zone. To make the Editor Zone stand out, click on its smart tab and choose AutoFormat and then Professional. Your design page should look more or less like Figure 12-56.


    Figure 12-56.  Editor Zone

    Moving a Part

    Run the application. When you log in and go to the Web Parts page, you are in Browse mode. Use the Display mode drop-down list to switch to Design mode and all the zones (except the Editing Zone) appear. You can now click on any Web Part (e.g., Today’s News) and drag it to any other zone, as shown in Figure 12-57.

    More Visual Basic.NET Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming Visual Basic 2005," published...
     

    Buy this book now. This article is excerpted from chapter 12 of the book Programming Visual Basic 2005, written by Jesse Liberty (O'Reilly, 2005; ISBN: 0596009496). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway