ControlBuilder.AllowWhitespaceLiterals 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷控制項開閉標籤間內容是否允許留白文字。 此方法稱為 ASP.NET 頁框架。
public:
virtual bool AllowWhitespaceLiterals();
public virtual bool AllowWhitespaceLiterals();
abstract member AllowWhitespaceLiterals : unit -> bool
override this.AllowWhitespaceLiterals : unit -> bool
Public Overridable Function AllowWhitespaceLiterals () As Boolean
傳回
一律傳回 true。
範例
// Create a class that does not allow white space generated by a control
// to be created as a LiteralControl.
[AspNetHostingPermission(SecurityAction.Demand,
Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class NoWhiteSpaceControlBuilder : ControlBuilder
{
public override bool AllowWhitespaceLiterals()
{
return false;
}
}
' Create a class that does not allow white space generated by a control
' to be created as a LiteralControl.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class NoWhiteSpaceControlBuilder
Inherits ControlBuilder
Public Overrides Function AllowWhitespaceLiterals() As Boolean
Return False
End Function 'AllowWhitespaceLiterals
End Class
備註
此 AllowWhitespaceLiterals 方法用於判斷控制項開頭與關閉標籤之間的內容是否允許留白文字。 當此方法回傳 false時,頁面解析器會先將空白文字從內容中裁掉,然後再處理內容。 當此方法返回 true時,空白欄位未被移除。
這個方法會由 ASP.NET 頁框架在解析時呼叫,並非直接在程式碼中呼叫。
給繼承者的注意事項
你可以在衍生類別中覆寫此方法,以指示自訂控制中是否允許使用空白欄位。