Sdílet prostřednictvím


ControlBuilder.SetTagInnerText(String) Metoda

Definice

ControlBuilder Poskytuje vnitřní text značky ovládacího prvku.

public:
 virtual void SetTagInnerText(System::String ^ text);
public virtual void SetTagInnerText(string text);
abstract member SetTagInnerText : string -> unit
override this.SetTagInnerText : string -> unit
Public Overridable Sub SetTagInnerText (text As String)

Parametry

text
String

Zadaný text.

Příklady

Následující příklad používá InDesigner vlastnost při NeedsTagInnerText zavolání metody. Pokud má ovládací prvek tento tvůrce připojený k němu, určuje, NeedsTagInnerText zda je ovládací prvek přístupný v době návrhu prostřednictvím návrháře. Vrátí NeedsTagInnerText hodnotu InDesigner vlastnosti a pak SetTagInnerText je volána metoda. Pokud je vlastnost nastavena InDesigner na false, je Exception vyvolán. V opačném případě se vnitřní text ovládacího prvku vrátí ve SetTagInnerText volání.

[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

Poznámky

Tato metoda je volána pouze v případě, že NeedsTagInnerText dříve vrácena true.

Platí pro