Control.IsLiteralContent Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan apakah kontrol server hanya menyimpan konten harfiah.
protected:
bool IsLiteralContent();
protected bool IsLiteralContent();
member this.IsLiteralContent : unit -> bool
Protected Function IsLiteralContent () As Boolean
Mengembalikan
true jika kontrol server hanya berisi konten harfiah; jika tidak false.
Contoh
Contoh berikut memeriksa apakah halaman yang berisi kontrol server telah diposting kembali. Jika sudah, ia memanggil IsLiteralContent metode untuk menentukan apakah kontrol hanya berisi konten harfiah, atau merupakan kontrol induk ke kontrol server lain. Jika berisi konten yang hanya harfiah, UniqueID properti yang LiteralControl mewakili konten tersebut ditulis ke respons.
// 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
Keterangan
Ketika metode ini mengembalikan true, koleksi kontrol server memegang satu kontrol harfiah.