PanelStyle, classe
Mise à jour : novembre 2007
Représente le style d'un contrôle Panel.
Assembly : System.Web (dans System.Web.dll)
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class PanelStyle : Style
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */ /** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */ public class PanelStyle extends Style
public class PanelStyle extends Style
La classe PanelStyle sert à représenter les paramètres de style d'un contrôle de panneau. Elle encapsule les propriétés qui contrôlent l'apparence d'un panneau et qui peuvent être appliquées à plusieurs contrôles de panneau afin d'uniformiser leur apparence.
Vous pouvez spécifier une image à afficher à l'arrière-plan du panneau en donnant une valeur à la propriété BackImageUrl. L'alignement horizontal du contenu du panneau est indiqué par la propriété HorizontalAlign. La direction des contrôles qui contiennent le texte au sein du contrôle de panneau peut être spécifiée en donnant une valeur à la propriété Direction.
L'exemple de code suivant montre comment créer un objet PanelStyle et paramétrer ses propriétés. Cet exemple se décompose en deux parties :
Une classe partielle, PanelStylecs_aspx, qui montre comment créer un nouvel objet PanelStyle et paramétrer ses propriétés.
Une page Web Forms qui utilise l'exemple PanelStylecs_aspx comme fichier de code-behind.
La première partie de l'exemple montre comment créer un objet PanelStyle, myPanelStyle, et paramétrer ses propriétés. La méthode ApplyStyle est ensuite appelée, à la fois pour le panneau Panel1 et le panneau Panel2, et myPanelStyle est appliquée au deux.
public partial class PanelStylecs_aspx : Page { void Page_Load(object sender, EventArgs e) { StateBag panelState = new StateBag(); PanelStyle myPanelStyle = new PanelStyle(panelState); // Set the properties of the PanelStyle class. myPanelStyle.HorizontalAlign = HorizontalAlign.Center; myPanelStyle.ScrollBars = ScrollBars.Both; myPanelStyle.Wrap = false; myPanelStyle.Direction = ContentDirection.LeftToRight; myPanelStyle.BackImageUrl = @"~\images\picture.jpg"; // Use the ApplyStyle method of the Panel control to apply // the settings from the myPanelStyle object. Panel1.ApplyStyle(myPanelStyle); Panel2.ApplyStyle(myPanelStyle); } }
La deuxième partie de l'exemple montre un fichier .aspx utilisé avec l'exemple précédent.
<%@ Page Language="C#" CodeFile="PanelStyle.cs" Inherits="PanelStylecs_aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>PanelStyle Example</title> </head> <body> <form id="form1" runat="server"> <h3>PanelStyle Example</h3> <asp:Panel id="Panel1" runat="server" width="150" height="50"> This is the Panel1 panel control. </asp:Panel> <br /><br /> <asp:Panel id="Panel2" runat="server" width="150" height="50"> This is the Panel2 panel control. </asp:Panel> </form> </body> </html>
- AspNetHostingPermission
pour opérer dans un environnement hébergé. Valeur de demande : LinkDemand ; valeur d'autorisation : Minimal
- AspNetHostingPermission
pour opérer dans un environnement hébergé. Valeur de demande : InheritanceDemand ; valeur d'autorisation : Minimal
System.MarshalByRefObject
System.ComponentModel.Component
System.Web.UI.WebControls.Style
System.Web.UI.WebControls.PanelStyle
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professionnel Édition x64, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.