.NET Framework Class Library LoginView Class Displays the appropriate content template for a given user, based on the user's authentication status and role membership.

Inheritance Hierarchy
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web (in System.Web.dll)

Syntax
<ThemeableAttribute(True)> _
<BindableAttribute(False)> _
Public Class LoginView _
Inherits Control _
Implements INamingContainer
[ThemeableAttribute(true)]
[BindableAttribute(false)]
public class LoginView : Control, INamingContainer
[ThemeableAttribute(true)]
[BindableAttribute(false)]
public ref class LoginView : public Control,
INamingContainer
[<ThemeableAttribute(true)>]
[<BindableAttribute(false)>]
type LoginView =
class
inherit Control
interface INamingContainer
end
The LoginView type exposes the following members.

Constructors
|
| Name | Description |
|---|
.gif) | LoginView | Initializes a new instance of the LoginView control. | Top

Methods
|
| Name | Description |
|---|
.gif) | AddedControl | Called after a child control is added to the Controls collection of the Control object. (Inherited from Control.) | .gif) | AddParsedSubObject | Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object. (Inherited from Control.) | .gif) | ApplyStyleSheetSkin | Applies the style properties defined in the page style sheet to the control. (Inherited from Control.) | .gif) | BuildProfileTree | Infrastructure. Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page. (Inherited from Control.) | .gif) | ClearCachedClientID | Infrastructure. Sets the cached ClientID value to nullNothingnullptra null reference (Nothing in Visual Basic). (Inherited from Control.) | .gif) | ClearChildControlState | Deletes the control-state information for the server control's child controls. (Inherited from Control.) | .gif) | ClearChildState | Deletes the view-state and control-state information for all the server control's child controls. (Inherited from Control.) | .gif) | ClearChildViewState | Deletes the view-state information for all the server control's child controls. (Inherited from Control.) | .gif) | ClearEffectiveClientIDMode | Infrastructure. Sets the ClientIDMode property of the current control instance and of any child controls to Inherit. (Inherited from Control.) | .gif) | CreateChildControls | Creates the child controls that make up the LoginView control. (Overrides Control..::.CreateChildControls()()().) | .gif) | CreateControlCollection | Creates a new ControlCollection object to hold the child controls (both literal and server) of the server control. (Inherited from Control.) | .gif) | DataBind()()() | Binds a data source to LoginView and all its child controls. (Overrides Control..::.DataBind()()().) | .gif) | DataBind(Boolean) | Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event. (Inherited from Control.) | .gif) | DataBindChildren | Binds a data source to the server control's child controls. (Inherited from Control.) | .gif) | Dispose | Enables a server control to perform final clean up before it is released from memory. (Inherited from Control.) | .gif) | EnsureChildControls | Determines whether the server control contains child controls. If it does not, it creates child controls. (Inherited from Control.) | .gif) | EnsureID | Creates an identifier for controls that do not have an identifier assigned. (Inherited from Control.) | .gif) | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | .gif) | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | .gif) | FindControl(String) | Searches the current naming container for a server control with the specified id parameter. (Inherited from Control.) | .gif) | FindControl(String, Int32) | Infrastructure. Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. You should not override this version of the FindControl method. (Inherited from Control.) | .gif) | Focus | Sets input focus to a control. (Overrides Control..::.Focus()()().) | .gif) | GetDesignModeState | Infrastructure. Gets design-time data for a control. (Inherited from Control.) | .gif) | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | .gif) | GetRouteUrl(Object) | Gets the URL that corresponds to a set of route parameters. (Inherited from Control.) | .gif) | GetRouteUrl(RouteValueDictionary) | Gets the URL that corresponds to a set of route parameters. (Inherited from Control.) | .gif) | GetRouteUrl(String, Object) | Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.) | .gif) | GetRouteUrl(String, RouteValueDictionary) | Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.) | .gif) | GetType | Gets the Type of the current instance. (Inherited from Object.) | .gif) | GetUniqueIDRelativeTo | Returns the prefixed portion of the UniqueID property of the specified control. (Inherited from Control.) | .gif) | HasControls | Determines if the server control contains any child controls. (Inherited from Control.) | .gif) | HasEvents | Returns a value indicating whether events are registered for the control or any child controls. (Inherited from Control.) | .gif) | IsLiteralContent | Infrastructure. Determines if the server control holds only literal content. (Inherited from Control.) | .gif) | LoadControlState | This method implements LoadControlState. (Overrides Control..::.LoadControlState(Object).) | .gif) | LoadViewState | Restores view-state information from a previous page request that was saved by the SaveViewState method. (Inherited from Control.) | .gif) | MapPathSecure | Retrieves the physical path that a virtual path, either absolute or relative, maps to. (Inherited from Control.) | .gif) | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | .gif) | OnBubbleEvent | Determines whether the event for the server control is passed up the page's UI server control hierarchy. (Inherited from Control.) | .gif) | OnDataBinding | Raises the DataBinding event. (Inherited from Control.) | .gif) | OnInit | Raises the Init event. (Overrides Control..::.OnInit(EventArgs).) | .gif) | OnLoad | Raises the Load event. (Inherited from Control.) | .gif) | OnPreRender | Determines which role-group template to display, based on the roles of the logged-in user. (Overrides Control..::.OnPreRender(EventArgs).) | .gif) | OnUnload | Raises the Unload event. (Inherited from Control.) | .gif) | OnViewChanged | Raises the ViewChanged event after the LoginView control switches views. | .gif) | OnViewChanging | Raises the ViewChanging event before the LoginView control switches views. | .gif) | OpenFile | Gets a Stream used to read a file. (Inherited from Control.) | .gif) | RaiseBubbleEvent | Assigns any sources of the event and its information to the control's parent. (Inherited from Control.) | .gif) | RemovedControl | Called after a child control is removed from the Controls collection of the Control object. (Inherited from Control.) | .gif) | Render | Infrastructure. Renders the Web server control content to the client's browser using the specified System.Web.UI..::.HtmlTextWriter object. (Overrides Control..::.Render(HtmlTextWriter).) | .gif) | RenderChildren | Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client. (Inherited from Control.) | .gif) | RenderControl(HtmlTextWriter) | Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled. (Inherited from Control.) | .gif) | RenderControl(HtmlTextWriter, ControlAdapter) | Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object. (Inherited from Control.) | .gif) | ResolveAdapter | Gets the control adapter responsible for rendering the specified control. (Inherited from Control.) | .gif) | ResolveClientUrl | Gets a URL that can be used by the browser. (Inherited from Control.) | .gif) | ResolveUrl | Converts a URL into one that is usable on the requesting client. (Inherited from Control.) | .gif) | SaveControlState | This method implements SaveControlState. (Overrides Control..::.SaveControlState()()().) | .gif) | SaveViewState | Saves any server control view-state changes that have occurred since the time the page was posted back to the server. (Inherited from Control.) | .gif) | SetDesignModeState | Sets design-time data for a control. (Overrides Control..::.SetDesignModeState(IDictionary).) | .gif) | SetRenderMethodDelegate | Infrastructure. Assigns an event handler delegate to render the server control and its content into its parent control. (Inherited from Control.) | .gif) | ToString | Returns a string that represents the current object. (Inherited from Object.) | .gif) | TrackViewState | Causes tracking of view-state changes to the server control so they can be stored in the server control's StateBag object. This object is accessible through the Control..::.ViewState property. (Inherited from Control.) | Top

Extension Methods

Explicit Interface Implementations
|
| Name | Description |
|---|
.gif) .gif) | IControlBuilderAccessor..::.ControlBuilder | For a description of this member, see IControlBuilderAccessor..::.ControlBuilder. (Inherited from Control.) | .gif) .gif) | IControlDesignerAccessor..::.GetDesignModeState | For a description of this member, see IControlDesignerAccessor..::.GetDesignModeState. (Inherited from Control.) | .gif) .gif) | IControlDesignerAccessor..::.SetDesignModeState | For a description of this member, see IControlDesignerAccessor..::.SetDesignModeState. (Inherited from Control.) | .gif) .gif) | IControlDesignerAccessor..::.SetOwnerControl | Infrastructure. For a description of this member, see IControlDesignerAccessor..::.SetOwnerControl. (Inherited from Control.) | .gif) .gif) | IControlDesignerAccessor..::.UserData | For a description of this member, see IControlDesignerAccessor..::.UserData. (Inherited from Control.) | .gif) .gif) | IDataBindingsAccessor..::.DataBindings | For a description of this member, see IDataBindingsAccessor..::.DataBindings. (Inherited from Control.) | .gif) .gif) | IDataBindingsAccessor..::.HasDataBindings | For a description of this member, see IDataBindingsAccessor..::.HasDataBindings. (Inherited from Control.) | .gif) .gif) | IExpressionsAccessor..::.Expressions | For a description of this member, see IExpressionsAccessor..::.Expressions. (Inherited from Control.) | .gif) .gif) | IExpressionsAccessor..::.HasExpressions | For a description of this member, see IExpressionsAccessor..::.HasExpressions. (Inherited from Control.) | .gif) .gif) | IParserAccessor..::.AddParsedSubObject | For a description of this member, see IParserAccessor..::.AddParsedSubObject. (Inherited from Control.) | Top

Remarks
In this topic: IntroductionThe LoginView control displays different Web site content templates (or "views") for different users, based on whether the user is authenticated and, if so, which Web site roles he or she belongs to. The template stored in the AnonymousTemplate property is displayed to any visitor to the Web site who has not logged in. Once a user is logged in, the site displays either a template associated with one of the user's roles in the RoleGroups property or the default template specified in the LoggedInTemplate property. The LoginView control manages switching among the various templates once you assign templates to any of the three template properties of the LoginView class:
AnonymousTemplate - Specifies the template to display to users who are not logged in to the Web site. Users who are logged in will never see this template.
LoggedInTemplate - Specifies the default template to display to users who are logged in to the Web site but do not belong to any role groups with defined templates.
RoleGroups - Specifies the template to display to logged-in users who are members of roles with defined role-group templates. Content templates are associated with particular sets of roles in RoleGroup instances.
Role-group templates are searched in the order they are defined in the source. The first matching role-group template is displayed to the user. If a user is a member of more than one role, the first role-group template that matches any of the user's roles is used. If more than one template is associated with a single role, only the first defined template is used. The following table describes the behavior of the LoginView control when various combinations of templates are used. LoggedIn Template Property | Anonymous Template Property | RoleGroups Property | LoginView behavior |
|---|
Not set | Not set | Not set | Displays no content. | Set | Not set | Not set | Displays content only when the user is logged in. | Not set | Set | Not set | Displays content only when the user is not logged in. | Not set | Not set | Set | Displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, displays no content. | Set | Set | Not set | If the user is logged in, displays the template specified in the LoggedInTemplate property. If the user in not logged in, displays the template specified in the AnonymousTemplate property. | Set | Set | Set | If the user is logged in, displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, displays the template specified in the LoggedInTemplate property. If the user is not logged in, displays the template specified in the AnonymousTemplate property. | Set | Not set | Set | If the user is logged in, displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, displays the template specified in the LoggedInTemplate property. If the user is not logged in, nothing is displayed. | Not set | Set | Set | If the user is logged in, displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, nothing is displayed. If the user is not logged in, displays the template specified in the AnonymousTemplate property. |
The AnonymousTemplate and LoggedInTemplate can be used with any authentication scheme that sets the Name property of the Page object's User property. You must configure role management to use the RoleGroups property to define templates base on the user's role on the Web site. For more information, see Understanding Role Management. The Focus method does not set the initial focus of the Web page to the LoginView control, or any of its child controls. Controls contained in the LoginView control are created after the PreRender event. To set the focus to a child control contained by the LoginView, handle the On_PreRender and call its Focus method. You can also use the ViewChanging and ViewChanged events to programmatically access the controls in the LoginView control templates. Declarative Syntax
<asp:LoginView
EnableTheming="True|False"
EnableViewState="True|False"
ID="string"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
OnViewChanged="ViewChanged event handler"
OnViewChanging="ViewChanging event handler"
runat="server"
SkinID="string"
Visible="True|False"
>
<AnonymousTemplate>
<!-- child controls -->
</AnonymousTemplate>
<LoggedInTemplate>
<!-- child controls -->
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup
Roles="string"
>
<ContentTemplate>
<!-- child controls -->
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>

Examples
The following code example shows how to set templates for each of the three template types supported by the LoginView control.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus></p>
<p>
<asp:LoginView id="LoginView1" runat="server">
<AnonymousTemplate>
Please log in for personalized information.
</AnonymousTemplate>
<LoggedInTemplate>
Thanks for logging in
<asp:LoginName id="LoginName1" runat="Server"></asp:LoginName>.
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup Roles="Admin">
<ContentTemplate>
<asp:LoginName id="LoginName2" runat="Server"></asp:LoginName>, you
are logged in as an administrator.
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView></p>
</form>
</body>
</html>
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus></p>
<p>
<asp:LoginView id="LoginView1" runat="server">
<AnonymousTemplate>
Please log in for personalized information.
</AnonymousTemplate>
<LoggedInTemplate>
Thanks for logging in
<asp:LoginName id="LoginName1" runat="Server"></asp:LoginName>.
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup Roles="Admin">
<ContentTemplate>
<asp:LoginName id="LoginName2" runat="Server"></asp:LoginName>, you
are logged in as an administrator.
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView></p>
</form>
</body>
</html>

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

See Also
|
Bibliothèque de classes .NET Framework LoginView, classe Affiche le modèle de contenu approprié pour un utilisateur donné, en fonction de l'état d'authentification et de l'appartenance à un rôle de l'utilisateur.

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
<ThemeableAttribute(True)> _
<BindableAttribute(False)> _
Public Class LoginView _
Inherits Control _
Implements INamingContainer
[ThemeableAttribute(true)]
[BindableAttribute(false)]
public class LoginView : Control, INamingContainer
[ThemeableAttribute(true)]
[BindableAttribute(false)]
public ref class LoginView : public Control,
INamingContainer
[<ThemeableAttribute(true)>]
[<BindableAttribute(false)>]
type LoginView =
class
inherit Control
interface INamingContainer
end
Le type LoginView expose les membres suivants.

Constructeurs
|
| Nom | Description |
|---|
.gif) | LoginView | Initialise une nouvelle instance du contrôle LoginView. | Début

Méthodes
|
| Nom | Description |
|---|
.gif) | AddedControl | Appelée après l'ajout d'un contrôle enfant à la collection Controls de l'objet Control. (Hérité de Control.) | .gif) | AddParsedSubObject | Avertit le contrôle serveur qu'un élément XML ou HTML a été analysé et l'ajoute à l'objet ControlCollection du contrôle serveur. (Hérité de Control.) | .gif) | ApplyStyleSheetSkin | Applique les propriétés de style définies dans la feuille de style de la page au contrôle. (Hérité de Control.) | .gif) | BuildProfileTree | Infrastructure. Collecte des informations sur le contrôle serveur et les livre à la propriété Trace à afficher lorsque le traçage est activé pour la page. (Hérité de Control.) | .gif) | ClearCachedClientID | Infrastructure. Affecte à la valeur ClientID mise en cache la valeur nullNothingnullptrune référence null (Nothing en Visual Basic). (Hérité de Control.) | .gif) | ClearChildControlState | Supprime les informations sur l'état du contrôle des contrôles enfants du contrôle serveur. (Hérité de Control.) | .gif) | ClearChildState | Supprime les informations sur l'état d'affichage et sur l'état du contrôle de tous les contrôles enfants du contrôle serveur. (Hérité de Control.) | .gif) | ClearChildViewState | Supprime les informations d'état d'affichage de tous les contrôles enfants du contrôle serveur. (Hérité de Control.) | .gif) | ClearEffectiveClientIDMode | Infrastructure. Affecte la valeur Inherit à la propriété ClientIDMode de l'instance de contrôle actuelle et de tous contrôles enfants. (Hérité de Control.) | .gif) | CreateChildControls | Crée les contrôles enfants qui composent le contrôle LoginView. (Substitue Control..::.CreateChildControls()()().) | .gif) | CreateControlCollection | Crée un nouvel objet ControlCollection pour contenir les contrôles enfants (littéraux et serveur) du contrôle serveur. (Hérité de Control.) | .gif) | DataBind()()() | Lie une source de données au LoginView et à tous ses contrôles enfants. (Substitue Control..::.DataBind()()().) | .gif) | DataBind(Boolean) | Lie une source de données au contrôle serveur appelé et tous ses contrôles enfants avec une option pour déclencher l'événement DataBinding. (Hérité de Control.) | .gif) | DataBindChildren | Lie une source de données aux contrôles enfants du contrôle serveur. (Hérité de Control.) | .gif) | Dispose | Permet à un contrôle serveur d'effectuer le nettoyage final avant qu'il soit libéré de la mémoire. (Hérité de Control.) | .gif) | EnsureChildControls | Détermine si le contrôle serveur contient des contrôles enfants. S'il ne contient pas de contrôles enfants, il en crée. (Hérité de Control.) | .gif) | EnsureID | Crée un identificateur pour les contrôles auxquels aucun identificateur n'est assigné. (Hérité de Control.) | .gif) | Equals(Object) | Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.) | .gif) | Finalize | Autorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.) | .gif) | FindControl(String) | Recherche un contrôle serveur possédant le paramètre id spécifié dans le conteneur d'attribution de noms actuel. (Hérité de Control.) | .gif) | FindControl(String, Int32) | Infrastructure. Recherche le conteneur d'attribution de noms actuel d'un contrôle serveur avec l'id spécifié et un entier, spécifié dans le paramètre pathOffset, qui facilite la recherche. Vous ne devez pas substituer cette version de la méthode FindControl. (Hérité de Control.) | .gif) | Focus | Affecte le focus d'entrée à un contrôle. (Substitue Control..::.Focus()()().) | .gif) | GetDesignModeState | Infrastructure. Obtient les données au moment du design pour un contrôle. (Hérité de Control.) | .gif) | GetHashCode | Sert de fonction de hachage pour un type particulier. (Hérité de Object.) | .gif) | GetRouteUrl(Object) | Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire. (Hérité de Control.) | .gif) | GetRouteUrl(RouteValueDictionary) | Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire. (Hérité de Control.) | .gif) | GetRouteUrl(String, Object) | Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire et à un nom d'itinéraire. (Hérité de Control.) | .gif) | GetRouteUrl(String, RouteValueDictionary) | Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire et à un nom d'itinéraire. (Hérité de Control.) | .gif) | GetType | Obtient le Type de l'instance actuelle. (Hérité de Object.) | .gif) | GetUniqueIDRelativeTo | Retourne la partie préfixée de la propriété UniqueID du contrôle spécifié. (Hérité de Control.) | .gif) | HasControls | Détermine si le contrôle serveur contient des contrôles enfants. (Hérité de Control.) | .gif) | HasEvents | Retourne une valeur indiquant si des événements sont inscrits pour le contrôle ou des contrôles enfants. (Hérité de Control.) | .gif) | IsLiteralContent | Infrastructure. Détermine si le contrôle serveur ne détient qu'un contenu littéral. (Hérité de Control.) | .gif) | LoadControlState | Cette méthode implémente LoadControlState. (Substitue Control..::.LoadControlState(Object).) | .gif) | LoadViewState | Restaure les informations d'état d'affichage à partir d'une demande de page antérieure enregistrée par la méthode SaveViewState. (Hérité de Control.) | .gif) | MapPathSecure | Récupère le chemin d'accès physique auquel un chemin d'accès virtuel, absolu ou relatif, correspond. (Hérité de Control.) | .gif) | MemberwiseClone | Crée une copie superficielle de l'objet Object actif. (Hérité de Object.) | .gif) | OnBubbleEvent | Détermine si l'événement pour le contrôle serveur est passé dans la hiérarchie des contrôles serveur de l'interface utilisateur de la page. (Hérité de Control.) | .gif) | OnDataBinding | Déclenche l'événement DataBinding. (Hérité de Control.) | .gif) | OnInit | Déclenche l'événement Init. (Substitue Control..::.OnInit(EventArgs).) | .gif) | OnLoad | Déclenche l'événement Load. (Hérité de Control.) | .gif) | OnPreRender | Détermine le modèle de groupe de rôles à afficher, en fonction des rôles de l'utilisateur connecté. (Substitue Control..::.OnPreRender(EventArgs).) | .gif) | OnUnload | Déclenche l'événement Unload. (Hérité de Control.) | .gif) | OnViewChanged | Déclenche l'événement ViewChanged après l'échange des vues par le contrôle LoginView. | .gif) | OnViewChanging | Déclenche l'événement ViewChanging avant l'échange des vues par le contrôle LoginView. | .gif) | OpenFile | Obtient un Stream utilisé pour lire un fichier. (Hérité de Control.) | .gif) | RaiseBubbleEvent | Assigne les sources éventuelles de l'événement et ses informations au parent du contrôle. (Hérité de Control.) | .gif) | RemovedControl | Appelée après la suppression d'un contrôle enfant dans la collection Controls de l'objet Control. (Hérité de Control.) | .gif) | Render | Infrastructure. Génère le rendu du contenu du contrôle serveur Web via le navigateur du client à l'aide de l'objet System.Web.UI..::.HtmlTextWriter spécifié. (Substitue Control..::.Render(HtmlTextWriter).) | .gif) | RenderChildren | Renvoie le contenu des enfants d'un contrôle serveur dans un objet HtmlTextWriter fourni, qui écrit le contenu à rendre sur le client. (Hérité de Control.) | .gif) | RenderControl(HtmlTextWriter) | Renvoie le contenu du contrôle serveur dans un objet HtmlTextWriter fourni et stocke des informations de traçage au sujet du contrôle si le traçage est activé. (Hérité de Control.) | .gif) | RenderControl(HtmlTextWriter, ControlAdapter) | Génère le contenu du contrôle serveur dans un objet HtmlTextWriter à l'aide d'un objet ControlAdapter fourni. (Hérité de Control.) | .gif) | ResolveAdapter | Obtient l'adaptateur de contrôles responsable du rendu du contrôle spécifié. (Hérité de Control.) | .gif) | ResolveClientUrl | Obtient une URL qui peut être utilisée par le navigateur. (Hérité de Control.) | .gif) | ResolveUrl | Convertit une URL en une URL que le client soit en mesure d'utiliser. (Hérité de Control.) | .gif) | SaveControlState | Cette méthode implémente SaveControlState. (Substitue Control..::.SaveControlState()()().) | .gif) | SaveViewState | Enregistre les modifications éventuellement apportées à l'état d'affichage du contrôle serveur depuis la publication de la page sur le serveur. (Hérité de Control.) | .gif) | SetDesignModeState | Définit les données au moment du design pour un contrôle. (Substitue Control..::.SetDesignModeState(IDictionary).) | .gif) | SetRenderMethodDelegate | Infrastructure. Assigne un délégué de gestionnaires d'événements pour générer le rendu du contrôle serveur et de son contenu dans son contrôle parent. (Hérité de Control.) | .gif) | ToString | Retourne une chaîne qui représente l'objet actuel. (Hérité de Object.) | .gif) | TrackViewState | Provoque le suivi des modifications de l'état d'affichage pour le contrôle serveur afin qu'elles puissent être stockées dans l'objet StateBag du contrôle serveur. Cet objet est accessible via la propriété Control..::.ViewState. (Hérité de Control.) | Début

Méthodes d'extension

Implémentations d'interface explicite
|
| Nom | Description |
|---|
.gif) .gif) | IControlBuilderAccessor..::.ControlBuilder | Pour obtenir une description de ce membre, consultez IControlBuilderAccessor..::.ControlBuilder. (Hérité de Control.) | .gif) .gif) | IControlDesignerAccessor..::.GetDesignModeState | Pour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.GetDesignModeState. (Hérité de Control.) | .gif) .gif) | IControlDesignerAccessor..::.SetDesignModeState | Pour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.SetDesignModeState. (Hérité de Control.) | .gif) .gif) | IControlDesignerAccessor..::.SetOwnerControl | Infrastructure. Pour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.SetOwnerControl. (Hérité de Control.) | .gif) .gif) | IControlDesignerAccessor..::.UserData | Pour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.UserData. (Hérité de Control.) | .gif) .gif) | IDataBindingsAccessor..::.DataBindings | Pour obtenir une description de ce membre, consultez IDataBindingsAccessor..::.DataBindings. (Hérité de Control.) | .gif) .gif) | IDataBindingsAccessor..::.HasDataBindings | Pour obtenir une description de ce membre, consultez IDataBindingsAccessor..::.HasDataBindings. (Hérité de Control.) | .gif) .gif) | IExpressionsAccessor..::.Expressions | Pour obtenir une description de ce membre, consultez IExpressionsAccessor..::.Expressions. (Hérité de Control.) | .gif) .gif) | IExpressionsAccessor..::.HasExpressions | Pour obtenir une description de ce membre, consultez IExpressionsAccessor..::.HasExpressions. (Hérité de Control.) | .gif) .gif) | IParserAccessor..::.AddParsedSubObject | Pour obtenir une description de ce membre, consultez IParserAccessor..::.AddParsedSubObject. (Hérité de Control.) | Début

Notes
Dans cette rubrique : IntroductionLe contrôle LoginView affiche les différents modèles de contenu de site Web (ou « affichages ») pour les différents utilisateurs, selon que l'utilisateur est authentifié ou non et, le cas échéant, les rôles de site Web auxquels il (elle) appartient. Le modèle stocké dans la propriété AnonymousTemplate est affiché à tout visiteur du site Web qui ne s'est pas identifié. Une fois qu'un utilisateur se connecte, le site affiche un modèle associé à l'un des rôles de l'utilisateur dans la propriété RoleGroups ou le modèle par défaut spécifié dans la propriété LoggedInTemplate. Le contrôle LoginView gère la permutation entre les différents modèles une fois que vous assignez ces derniers à l'une des trois propriétés de modèle de la classe LoginView :
AnonymousTemplate - Spécifie le modèle à afficher pour les utilisateurs qui ne sont pas connectés au site Web. Les utilisateurs connectés ne verront jamais ce modèle.
LoggedInTemplate - Spécifie le modèle par défaut à afficher pour les utilisateurs connectés au site Web, mais qui n'appartiennent à aucun groupe de rôles avec des modèles définis.
RoleGroups - Spécifie le modèle à afficher pour les utilisateurs connectés qui sont membres de rôles avec des modèles de groupe de rôles définis. Les modèles de contenu sont associés à des ensembles de rôles particuliers dans les instances de RoleGroup.
Les modèles de groupe de rôles sont recherchés suivant l'ordre dans lequel ils sont définis dans la source. Le premier modèle de groupe de rôles de correspondance s'affiche à l'intention de l'utilisateur. Si l'utilisateur est membre de plusieurs rôles, le premier modèle de groupe de rôles qui correspond à un des rôles de l'utilisateur est utilisé. Si plusieurs modèles sont associés à un rôle unique, seul le premier modèle défini est utilisé. Le tableau suivant décrit le comportement du contrôle LoginView lorsque plusieurs combinaisons de modèles sont utilisées. Propriété de modèle LoggedIn | Propriété de modèle anonyme | Propriété RoleGroups | Comportement LoginView |
|---|
Non définie | Non définie | Non définie | N'affiche aucun contenu. | Set | Non définie | Non définie | Affiche le contenu uniquement lorsque l'utilisateur est connecté. | Non définie | Set | Non définie | Affiche le contenu uniquement lorsque l'utilisateur n'est pas connecté. | Non définie | Non définie | Set | Affiche le premier modèle de la collection RoleGroups qui correspond à l'un des rôles de l'utilisateur. Si aucune correspondance n'est trouvée, n'affiche aucun contenu. | Set | Set | Non définie | Si l'utilisateur est connecté, affiche le modèle spécifié dans la propriété LoggedInTemplate. Si l'utilisateur n'est pas connecté, affiche le modèle spécifié dans la propriété AnonymousTemplate. | Set | Set | Set | Si l'utilisateur est connecté, affiche le premier modèle de la collection RoleGroups qui correspond à l'un des rôles de l'utilisateur. Si aucune correspondance n'est trouvée, affiche le modèle spécifié dans la propriété LoggedInTemplate. Si l'utilisateur n'est pas connecté, affiche le modèle spécifié dans la propriété AnonymousTemplate. | Set | Non définie | Set | Si l'utilisateur est connecté, affiche le premier modèle de la collection RoleGroups qui correspond à l'un des rôles de l'utilisateur. Si aucune correspondance n'est trouvée, affiche le modèle spécifié dans la propriété LoggedInTemplate. Si l'utilisateur n'est pas connecté, rien ne s'affiche. | Non définie | Set | Set | Si l'utilisateur est connecté, affiche le premier modèle de la collection RoleGroups qui correspond à l'un des rôles de l'utilisateur. Si aucune correspondance n'est trouvée, rien ne s'affiche. Si l'utilisateur n'est pas connecté, affiche le modèle spécifié dans la propriété AnonymousTemplate. |
Les AnonymousTemplate et LoggedInTemplate peuvent être utilisés avec n'importe quel schéma d'authentification qui définit la propriété Name de la propriété User de l'objet Page. Vous devez configurer la gestion des rôles pour utiliser la propriété RoleGroups afin de définir les modèles en fonction du rôle de l'utilisateur sur le site Web. Pour plus d'informations, consultez Présentation de la gestion des rôles. La méthode Focus n'affecte pas le contrôle LoginView, ou un de ses contrôles enfants, au focus initial de la page Web. Les contrôles contenus dans le contrôle LoginView sont créés après l'événement PreRender. Pour affecter le focus à un contrôle enfant que contient le LoginView, gérez le On_PreRender et appelez sa méthode Focus. Vous pouvez également utiliser les événements ViewChanging et ViewChanged pour accéder par programme aux contrôles des modèles de contrôle LoginView. Syntaxe déclarative
<asp:LoginView
EnableTheming="True|False"
EnableViewState="True|False"
ID="string"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
OnViewChanged="ViewChanged event handler"
OnViewChanging="ViewChanging event handler"
runat="server"
SkinID="string"
Visible="True|False"
>
<AnonymousTemplate>
<!-- child controls -->
</AnonymousTemplate>
<LoggedInTemplate>
<!-- child controls -->
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup
Roles="string"
>
<ContentTemplate>
<!-- child controls -->
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>

Exemples
L'exemple de code suivant montre comment définir des modèles pour chacun des trois types de modèles pris en charge par le contrôle LoginView.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus></p>
<p>
<asp:LoginView id="LoginView1" runat="server">
<AnonymousTemplate>
Please log in for personalized information.
</AnonymousTemplate>
<LoggedInTemplate>
Thanks for logging in
<asp:LoginName id="LoginName1" runat="Server"></asp:LoginName>.
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup Roles="Admin">
<ContentTemplate>
<asp:LoginName id="LoginName2" runat="Server"></asp:LoginName>, you
are logged in as an administrator.
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView></p>
</form>
</body>
</html>
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus></p>
<p>
<asp:LoginView id="LoginView1" runat="server">
<AnonymousTemplate>
Please log in for personalized information.
</AnonymousTemplate>
<LoggedInTemplate>
Thanks for logging in
<asp:LoginName id="LoginName1" runat="Server"></asp:LoginName>.
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup Roles="Admin">
<ContentTemplate>
<asp:LoginName id="LoginName2" runat="Server"></asp:LoginName>, you
are logged in as an administrator.
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView></p>
</form>
</body>
</html>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Sécurité des threads
Tous les membres static ( Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi
RéférenceAutres ressources
|