Panel Class
Provides a container for organizing controls in a mobile Web forms page.
Assembly: System.Web.Mobile (in System.Web.Mobile.dll)
[DesignerAdapterAttribute(typeof(HtmlPanelAdapter))] [AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class Panel : public MobileControl, ITemplateable
<mobile:Panel />
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:
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Web.UI::Control
System.Web.UI.MobileControls::MobileControl
System.Web.UI.MobileControls::Panel
System.Web.UI.MobileControls::Form
System.Web.UI.MobileControls::TemplateContainer
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.