ControlBuilder.InDesigner Właściwość

Definicja

Zwraca, ControlBuilder czy element jest uruchomiony w projektancie.

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

Wartość właściwości

Boolean

true jeśli element ControlBuilder jest uruchomiony w projektancie; falsew przeciwnym razie .

Przykłady

W poniższym przykładzie użyto InDesigner właściwości podczas wywoływanej NeedsTagInnerText metody. Gdy ten konstruktor jest do niego dołączony, metoda określa, NeedsTagInnerText czy kontrola jest uzyskiwana w czasie projektowania za pośrednictwem projektanta. Zwraca NeedsTagInnerText wartość InDesigner właściwości, a następnie wywoływaną metodę SetTagInnerText . Jeśli właściwość jest ustawiona InDesigner na false, Exception jest zgłaszana wartość . W przeciwnym razie tekst wewnętrzny kontrolki jest zwracany w wywołaniu 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

Dotyczy