Control.IsLiteralContent メソッド
定義
サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。Determines if the server control holds only literal content.
protected:
bool IsLiteralContent();
protected bool IsLiteralContent ();
member this.IsLiteralContent : unit -> bool
Protected Function IsLiteralContent () As Boolean
戻り値
サーバー コントロールがリテラルな内容だけを含む場合は true
。それ以外の場合は false
。true
if the server control contains solely literal content; otherwise false
.
例
次の例では、サーバーコントロールを含むページがポストバックされたかどうかを確認します。The following example checks whether the page that contains the server controls has posted back. 存在する場合は、IsLiteralContent メソッドを呼び出して、コントロールにリテラルコンテンツだけが含まれているか、他のサーバーコントロールの親コントロールであるかを確認します。If it has, it calls the IsLiteralContent method to determine whether the control contains just literal content, or is a parent control to other server controls. 単にリテラルコンテンツが含まれている場合は、そのコンテンツを表す LiteralControl の UniqueID プロパティが応答に書き込まれます。If it contains solely literal content, the UniqueID property of the LiteralControl that represents that content is written to the response.
// Override the OnLoad method to check if the
// page that uses this control has posted back.
// If so, check whether this controls contains
// only literal content, and if it does,
// it gets the UniqueID property and writes it
// to the page. Otherwise, it writes a message
// that the control contains more than literal content.
protected override void OnLoad(EventArgs e)
{
if (Page.IsPostBack)
{
String s;
if (this.IsLiteralContent())
{
s = Controls[0].UniqueID;
Context.Response.Write(s);
}
else
{
Context.Response.Write(
"The control contains more than literal content.");
}
}
}
' Override the OnLoad method to check if the
' page that uses this control has posted back.
' If so, check whether this controls contains
' only literal content, and if it does,
' it gets the UniqueID property and writes it
' to the page. Otherwise, it writes a message
' that the control contains more than literal content.
Overrides Protected Sub OnLoad(ByVal e As EventArgs)
If Page.IsPostBack = True Then
Dim s As String
If Me.IsLiteralContent() = True Then
s = Controls(0).UniqueID
Context.Response.Write(s)
Else
Context.Response.Write( _
"The control contains more than literal content.")
End If
End If
End Sub
注釈
このメソッドが true
を返す場合、サーバーコントロールのコレクションは1つのリテラルコントロールを保持します。When this method returns true
, the server control's collection holds a single literal control.