ControlBuilder.InDesigner 속성

정의

ControlBuilder가 디자이너에서 실행되고 있는지 여부를 반환합니다.

protected:
 property bool InDesigner { bool get(); };
protected bool InDesigner { get; }
member this.InDesigner : bool
Protected ReadOnly Property InDesigner As Boolean

속성 값

Boolean

ControlBuilder가 디자이너에서 실행되고 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 메서드가 InDesigner 호출 될 때 NeedsTagInnerText 속성을 사용 합니다. 컨트롤에 이 작성기가 연결된 경우 NeedsTagInnerText 메서드는 디자이너를 통해 디자인 타임에 컨트롤에 액세스할지 여부를 결정합니다. 속성 NeedsTagInnerText 값을 InDesigner 반환한 다음 메서드가 SetTagInnerText 호출됩니다. 속성이 InDesigner 설정된 false경우 throw Exception 됩니다. 그렇지 않으면 호출에서 컨트롤의 내부 텍스트가 SetTagInnerText 반환됩니다.

[AspNetHostingPermission(SecurityAction.Demand, 
    Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class MyControlControlBuilder : ControlBuilder
{
    private string _innerText;

    public override bool NeedsTagInnerText()
    {
        return InDesigner;
    }

    public override void SetTagInnerText(string text)
    {
        if (!InDesigner)
            throw new Exception("The control is not in design mode.");
        else
            _innerText = text;
    }
}
<AspNetHostingPermission(SecurityAction.Demand, _
  Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class MyControlControlBuilder
  Inherits ControlBuilder
    
    Private _innerText As String
    
    Overrides Public Function NeedsTagInnerText() As Boolean
      Return InDesigner
    End Function
    
    Overrides Public Sub SetTagInnerText(ByVal text As String)        
       If InDesigner = False
         Throw New System.Exception("The control is not in design mode.")
       Else
         _innerText = text
       End If
    End Sub
    
End Class

적용 대상