共用方式為


ControlBuilder.SetTagInnerText(String) 方法

定義

提供控制項標記內部文字給 ControlBuilder

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)

參數

text
String

要提供的文字。

範例

下列範例會在 InDesigner 呼叫 方法時 NeedsTagInnerText 使用 屬性。 當控制項附加這個產生器時,會 NeedsTagInnerText 決定控制項是否在設計階段透過設計工具存取。 會 NeedsTagInnerText 傳回 屬性的值 InDesigner ,然後 SetTagInnerText 呼叫 方法。 InDesigner如果 屬性設定為 falseException 則會擲回 。 否則,會在呼叫時 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

備註

只有在先前傳 true 回 時 NeedsTagInnerText ,才會呼叫這個方法。

適用於