LoginDesigner クラス
アセンブリ: System.Design (system.design.dll 内)


Login コントロールはユーザー インターフェイスを表示します。ユーザーは、このユーザー インターフェイスを使用してホストの Web サイトにログオンできます。
ビジュアルなデザイナでソース ビューからデザイン ビューに切り替えると、Login コントロールを記述するマークアップのソース コードが解析され、コントロールのデザイン時バージョンがデザイン サーフェイスに作成されます。元のソース ビューに切り替えると、デザイン時コントロールがマークアップのソース コードに永続化され、Web ページのマークアップに反映されます。LoginDesigner クラスは、Login コントロールをデザイン時に使用できるようにします。
LoginDesigner クラスのプロパティは、次の機能を提供します。
-
ActionLists プロパティは、DesignerActionListCollection オブジェクトを返します。一般にこのオブジェクトには、デザイナの継承ツリーの各レベルについて、DesignerActionList クラスから派生したオブジェクトが格納されます。
-
AutoFormats プロパティは、[オートフォーマット] ダイアログ ボックスで表示するための書式指定スキームのコレクションを返します。
-
TemplateGroups プロパティは、関連付けられた Login コントロールとトップレベルの Login テンプレートのフィールドに対して、テンプレート グループのコレクションを返します。
-
UsePreviewControl プロパティは、常に true を返します。デザイナは、関連付けられた Login の一時的なコピーを作成して、デザイン時のマークアップを生成します。
LoginDesigner クラスのメソッドは、次の機能を提供します。
-
GetDesignTimeHtml メソッドは、デザイン時に、関連付けられた Login のレンダリングに使用するマークアップを返します。
-
GetEditableDesignerRegionContent メソッドは、関連付けられた Login に対して、テンプレートのシリアル化されたコピーを返します。
-
GetErrorDesignTimeHtml メソッドは、エラーが発生したときに、関連付けられた Login のデザイン時表示に使用するマークアップを提供します。
-
PreFilterProperties メソッドは、関連付けられた Login のプロパティの削除、追加、およびシャドウに使用します。
-
SetEditableDesignerRegionContent メソッドは、コントロール テンプレートのシリアル化されたコピーから、関連付けられた Login の領域を設定します。

LoginDesigner クラスを拡張し、Login コントロールから派生したコントロールの外観をデザイン時に変更するコード例を次に示します。
この例では、MyLogin コントロールを Login から派生させています。MyLogin は、Login コントロールのコピーです。また、この例では、MyLoginDesigner クラスを LoginDesigner から派生させ、MyLoginDesigner の DesignerAttribute 属性を MyLogin コントロールに適用しています。
MyLoginDesigner は、PreFilterProperties メソッドをオーバーライドし、デザイン時に、[プロパティ] グリッドに NamingContainer プロパティを表示します。MyLogin コントロールの BorderStyle プロパティの値が NotSet または None の場合、GetDesignTimeHtml メソッドをオーバーライドし、コントロールの周囲に青い点線の境界線を描画して、コントロールの範囲をわかりやすくしています。GetErrorDesignTimeHtml メソッドをオーバーライドして、赤の太字で表示されるエラー メッセージを含んだプレースホルダのマークアップを生成しています。
Imports System Imports System.Web Imports System.Drawing Imports System.Web.UI.WebControls Imports System.Web.UI.Design.WebControls Imports System.Collections Imports System.ComponentModel Imports System.Security.Permissions Namespace Examples.VB.WebControls.Design ' The MyLogin is a copy of the Login. <AspNetHostingPermission(SecurityAction.Demand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermission(SecurityAction.InheritanceDemand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <Designer(GetType(Examples.VB.WebControls.Design.MyLoginDesigner))> _ Public Class MyLogin Inherits Login End Class ' MyLogin ' Override members of the LoginDesigner. <ReflectionPermission(SecurityAction.Demand, Flags:=ReflectionPermissionFlag.MemberAccess)> _ Public Class MyLoginDesigner Inherits LoginDesigner ' Generate the design-time markup for the control when an error occurs. Protected Overrides Function GetErrorDesignTimeHtml( _ ByVal ex As Exception) As String ' Write the error message text in red, bold. Dim errorRendering As String = _ "<span style=""font-weight:bold; color:Red; "">" & _ ex.Message & "</span>" Return CreatePlaceHolderDesignTimeHtml(errorRendering) End Function ' GetErrorDesignTimeHtml ' Shadow the control properties with design-time properties. Protected Overrides Sub PreFilterProperties( _ ByVal properties As IDictionary) ' Call the base method first. MyBase.PreFilterProperties(properties) ' Make the NamingContainer visible in the Properties grid. Dim selectProp As PropertyDescriptor = _ CType(properties("NamingContainer"), PropertyDescriptor) properties("NamingContainer") = _ TypeDescriptor.CreateProperty(selectProp.ComponentType, _ selectProp, BrowsableAttribute.Yes) End Sub ' PreFilterProperties ' Generate the design-time markup. Public Overrides Function GetDesignTimeHtml() As String ' Make the control more visible in the designer. If the border ' style is None or NotSet, change the border to a blue dashed line. Dim myLoginCtl As MyLogin = CType(ViewControl, MyLogin) Dim markup As String = Nothing ' Check if the border style should be changed. If (myLoginCtl.BorderStyle = BorderStyle.NotSet Or _ myLoginCtl.BorderStyle = BorderStyle.None) Then Dim oldBorderStyle As BorderStyle = myLoginCtl.BorderStyle Dim oldBorderColor As Color = myLoginCtl.BorderColor ' Set the design time properties and catch any exceptions. Try myLoginCtl.BorderStyle = BorderStyle.Dashed myLoginCtl.BorderColor = Color.Blue ' Call the base method to generate the markup. markup = MyBase.GetDesignTimeHtml() Catch ex As Exception 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 End Try Else ' Call the base method to generate the markup. markup = MyBase.GetDesignTimeHtml() End If Return markup End Function ' GetDesignTimeHtml End Class ' MyLoginDesigner End Namespace ' Examples.VB.WebControls.Design
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. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [Designer(typeof(Examples.CS.WebControls.Design.MyLoginDesigner))] 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. base.PreFilterProperties(properties); // Make the NamingContainer visible in the Properties grid. PropertyDescriptor selectProp = (PropertyDescriptor)properties["NamingContainer"]; properties["NamingContainer"] = TypeDescriptor.CreateProperty(selectProp.ComponentType, 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. try { 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); } 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 } // MyLoginDesigner } // Examples.CS.WebControls.Design

- SecurityPermission (LoginDesigner の使用時にアンマネージ コードを呼び出すために必要なアクセス許可)。要求値 : Demand。アクセス許可値 : UnmanagedCode。

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.LoginDesigner


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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- LoginDesigner クラスのページへのリンク