Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

Panel Class

Provides a container for organizing controls in a mobile Web forms page.

Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile (in system.web.mobile.dll)

public class Panel : MobileControl, ITemplateable
public class Panel extends MobileControl implements ITemplateable
public class Panel extends MobileControl implements ITemplateable

Panels are container controls that can be nested. Attributes set on a panel are inherited by the controls that are contained in that panel.

You can use a panel for any of the following functions:

  • Grouping controls logically so that they can be shown or hidden.

  • Defining a convenient container where controls can be created or removed dynamically.

  • Using a single point to apply style attributes to a set of controls, by setting them on the panel. Because style inheritance applies to panels, attributes that are set on a panel can be inherited by controls that are contained in that panel.

  • Providing information to the ASP.NET page framework about which controls to keep together when paginating. By default, the contents of a panel are kept together on a page. You can modify this behavior by setting the Paginate property for the panel.

You can include literal text together with its accompanying markup tags in the text contents of the Panel. For more information, see Literal Text Inside Form Markup.

The following code example demonstrates how to set properties for a panel during page load and how to define functions to manipulate properties for a panel so that they respond to command clicks. At page load, the code also looks for and modifies a label within a device-specific content template in a second panel.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Drawing" %>

<script runat="server">
    public void Page_Load(Object sender, EventArgs e)
    {
        // Set Panel1 properties
        Panel1.Wrapping = Wrapping.NoWrap;
        Panel1.Alignment = Alignment.Center;
        Panel1.StyleReference = "title";

        // Find Label in Panel2
        Control ctl = Panel2.Content.FindControl("lblStatusToday");
        if (ctl != null)
            ((System.Web.UI.MobileControls.Label)ctl).Text
                = "I found this label";
    }
    
    public void MakeFontRed(Object sender, EventArgs e)
    {
        Panel1.ForeColor = Color.Red;
    }
    
    public void MakeFontBlue(Object sender, EventArgs e)
    {
        Panel1.ForeColor = Color.Blue;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form runat="server" id="Form1">
    <!-- First Panel -->
    <mobile:Panel runat="server" id="Panel1">
        <mobile:TextView runat="server" id="TextView1">
            A Panel provides a grouping mechanism<br />
            for organizing controls.
        </mobile:TextView>
    </mobile:Panel>
    <mobile:Command runat="server" id="Command1"  BreakAfter="false"
        Text="Make Font Red" OnClick="MakeFontRed"/>
    <mobile:Command runat="server" id="Command2" BreakAfter="true"
        Text="Make Font Blue" OnClick="MakeFontBlue"/>

    <!-- Second Panel -->
    <mobile:Panel ID="Panel2"  Runat="server">
        <mobile:DeviceSpecific id="DeviceSpecific1" runat="server">
            <!-- Filter and template for HTML32 devices -->
            <Choice Filter="isHTML32" 
                Xmlns="http://schemas.microsoft.com/mobile/html32template">
                <ContentTemplate>
                    <mobile:Label id="Label1" runat="server">
                        HTML32 Template</mobile:Label>
                    <mobile:Label ID="lblStatusToday" Runat="server"/>
                </ContentTemplate>
            </Choice>
            <!-- Default filter and template -->
            <Choice>
                <ContentTemplate>
                    <mobile:Label ID="Label1" Runat="server">
                        Default Template</mobile:Label>
                    <mobile:Label ID="lblStatusToday" Runat="server" />
                </ContentTemplate>
            </Choice>
        </mobile:DeviceSpecific>
    </mobile:Panel>
</mobile:Form>
</body>
</html>

You will also need to add this section to your Web.config file:

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.