Export (0) Print
Expand All

LoginStatusDesigner Class

Provides design-time support in a visual designer for the LoginStatus Web server control.

Namespace: System.Web.UI.Design.WebControls
Assembly: System.Design (in system.design.dll)

public class LoginStatusDesigner : CompositeControlDesigner
public class LoginStatusDesigner extends CompositeControlDesigner
public class LoginStatusDesigner extends CompositeControlDesigner
Not applicable.

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

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 Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft