Control.IsLiteralContent Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Returns
true
if the server control contains solely literal content; otherwise false
.
Examples
The following example checks whether the page that contains the server controls has posted back. 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. 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
Remarks
When this method returns true
, the server control's collection holds a single literal control.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기