LoginDesigner Class

Note: This class is new in the .NET Framework version 2.0.

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

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

public class LoginDesigner : CompositeControlDesigner
public class LoginDesigner extends CompositeControlDesigner
public class LoginDesigner extends CompositeControlDesigner

The Login control displays a user interface that allows a user to log on to the host Web site.

In a visual designer, when you switch from Source to Design view, the markup source code that describes the Login 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 LoginDesigner class provides design-time support for the Login control.

The LoginDesigner class properties provide the following functionality:

  • 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 AutoFormats property returns a collection of formatting schemes for display in the Auto Format dialog box.

  • The TemplateGroups property returns a collection of template groups for the fields of the associated Login control and the top-level Login template.

  • The UsePreviewControl property always returns true, indicating that the designer creates a temporary copy of the associated Login to generate the design-time markup.

The LoginDesigner class methods provide the following functionality:

  • The GetDesignTimeHtml method returns the markup that is used to render the associated Login at design time.

  • The GetEditableDesignerRegionContent method returns a serialized copy of the template for the associated Login.

  • The GetErrorDesignTimeHtml method provides the markup that is used to render the associated Login at design time when an error has occurred.

  • The Initialize method prepares the designer to view, edit, and design the associated Login.

  • The PreFilterProperties method is used to remove properties from, add additional properties to, or shadow properties of the associated Login.

  • The SetEditableDesignerRegionContent method sets a region of the associated Login from a serialized copy of a control template.

The following code example shows how to extend the LoginDesigner class to change the appearance of controls that are derived from the Login control at design time.

The example derives the MyLogin control from the Login. The MyLogin is a copy of the Login control. The example also derives the MyLoginDesigner class from the LoginDesigner and applies a DesignerAttribute attribute for the MyLoginDesigner on the MyLogin control.

The MyLoginDesigner overrides the PreFilterProperties method to make the NamingContainer property visible in the Properties grid at design time. It overrides the GetDesignTimeHtml method to draw a blue, dashed border around the control to make its extent more visible, if the BorderStyle property of the MyLogin control is the NotSet or None value. It overrides the GetErrorDesignTimeHtml method to generate the markup for a placeholder that includes the error message rendered in red, bold text.

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;

namespace Examples.CS.WebControls.Design
    // The MyLogin is a copy of the Login.
        Level = AspNetHostingPermissionLevel.Minimal)]
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyLogin : Login
    } // MyLogin

    // Override members of the LoginDesigner.
    [ReflectionPermission(SecurityAction.Demand, Flags=ReflectionPermissionFlag.MemberAccess)]
    public class MyLoginDesigner : LoginDesigner
        // Generate the design-time markup for the control when an error occurs.
        protected override string GetErrorDesignTimeHtml(Exception e) 
            // Write the error message text in red, bold.
            string errorRendering =
                "<span style=\"font-weight:bold; color:Red; \">" +
                e.Message + "</span>";

            return CreatePlaceHolderDesignTimeHtml(errorRendering);
        } // GetErrorDesignTimeHtml

        // Shadow the control properties with design-time properties.
        protected override void PreFilterProperties(IDictionary properties)
            // Call the base method first.

            // Make the NamingContainer visible in the Properties grid.
            PropertyDescriptor selectProp = 
            properties["NamingContainer"] =
                    selectProp, BrowsableAttribute.Yes);
        } // PreFilterProperties

        // 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. 
            MyLogin myLoginCtl = (MyLogin)ViewControl;
            string markup = null;

            // Check if the border style should be changed.
            if (myLoginCtl.BorderStyle == BorderStyle.NotSet ||
                myLoginCtl.BorderStyle == BorderStyle.None)
                BorderStyle oldBorderStyle = myLoginCtl.BorderStyle;
                Color oldBorderColor = myLoginCtl.BorderColor;

                // Set the design time properties and catch any exceptions.
                    myLoginCtl.BorderStyle = BorderStyle.Dashed;
                    myLoginCtl.BorderColor = Color.Blue;

                    // Call the base method to generate the markup.
                    markup = base.GetDesignTimeHtml();
                catch (Exception ex)
                    markup = GetErrorDesignTimeHtml(ex);
                    // 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;
                // Call the base method to generate the markup.
                markup = base.GetDesignTimeHtml();

            return markup;

        } // GetDesignTimeHtml
    } // MyLoginDesigner
} // 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 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.

.NET Framework

Supported in: 2.0