LoginStatusDesigner Class
Assembly: System.Design (in system.design.dll)
The LoginStatus control renders a button that automatically checks the authentication status of the user and displays the appropriate login or logout option.
In a visual designer, when you switch from Source to Design view, the markup source code that describes the LoginStatus control is parsed and a design-time version of the control is created on the design surface. When you switch back to Source view, the design-time control is persisted to the markup source code and edited into the markup for the Web page. The LoginStatusDesigner class provides design-time support for the LoginStatus control.
The ActionLists property returns a DesignerActionListCollection object, which typically contains an object that is derived from the DesignerActionList class for each level in the inheritance tree of the designer. The UsePreviewControl property always returns true, indicating that the designer creates a temporary copy of the associated LoginStatus to generate the design-time markup, since the user authentication status is not available at design time.
The GetDesignTimeHtml method returns the markup that is used to render the associated LoginStatus at design time. The Initialize method prepares the designer to view, edit, and design the associated LoginStatus.
The following code example shows how to extend the LoginStatusDesigner class to change the appearance of controls that are derived from the LoginStatus control at design time.
The example derives the MyLoginStatus control from the LoginStatus. The MyLoginStatus is a copy of the LoginStatus control. The example also derives the MyLoginStatusDesigner class from LoginStatusDesigner, and then applies a DesignerAttribute attribute for the MyLoginStatusDesigner on the MyLoginStatus control.
The MyLoginStatusDesigner overrides the GetDesignTimeHtml method to draw a blue, dashed border around the control to make it more visible, if the BorderStyle property of the MyLoginStatus is the NotSet or None value.
using System; using System.Web; using System.Drawing; using System.Web.UI.WebControls; using System.Web.UI.Design.WebControls; using System.Collections; using System.ComponentModel; using System.Security.Permissions; using System.IO; namespace Examples.CS.WebControls.Design { // The MyLoginStatus is a copy of the LoginStatus. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [Designer(typeof(Examples.CS.WebControls.Design.MyLoginStatusDesigner))] public class MyLoginStatus : LoginStatus { } // MyLoginStatus // Override members of the LoginStatusDesigner. public class MyLoginStatusDesigner : LoginStatusDesigner { // Generate the design-time markup. public override string GetDesignTimeHtml() { // Make the control more visible in the designer. If the border // style is None or NotSet, change the border to a blue dashed line. MyLoginStatus myLoginStatusCtl = (MyLoginStatus)ViewControl; string markup = null; // Check if the border style should be changed. if (myLoginStatusCtl.BorderStyle == BorderStyle.NotSet || myLoginStatusCtl.BorderStyle == BorderStyle.None) { BorderStyle oldBorderStyle = myLoginStatusCtl.BorderStyle; Color oldBorderColor = myLoginStatusCtl.BorderColor; // Set the design time properties and catch any exceptions. try { myLoginStatusCtl.BorderStyle = BorderStyle.Dashed; myLoginStatusCtl.BorderColor = Color.Blue; // Call the base method to generate the markup. markup = base.GetDesignTimeHtml(); } catch (Exception ex) { markup = GetErrorDesignTimeHtml(ex); } finally { // It is not necessary to restore the border properties // to their original values because the ViewControl // was used to reference the associated control and the // UsePreviewControl was not overridden. // myLoginCtl.BorderStyle = oldBorderStyle; // myLoginCtl.BorderColor = oldBorderColor; } } else // Call the base method to generate the markup. markup = base.GetDesignTimeHtml(); return markup; } // GetDesignTimeHtml } // MyLoginStatusDesigner } // Examples.CS.WebControls.Design
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.WebControls.CompositeControlDesigner
System.Web.UI.Design.WebControls.LoginStatusDesigner
Windows 98, Windows 2000 SP4, 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.
Reference
LoginStatusDesigner MembersSystem.Web.UI.Design.WebControls Namespace
LoginStatus
CompositeControl
WebControl
CompositeControlDesigner Class
ControlDesigner Class
HtmlControlDesigner Class
ComponentDesigner
Other Resources
ASP.NET Control Designers OverviewWalkthrough: Creating a Basic Control Designer for a Web Server Control