ControlBuilder.AllowWhitespaceLiterals 方法

定義

判斷控制項的開頭和結尾標記之間的內容是否允許空白字元常值。 此方法由 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

傳回

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 網頁架構呼叫,而且不適合直接在您程式碼中呼叫。

給繼承者的注意事項

您可以在衍生類別中覆寫這個方法,以指出自訂控制項中是否允許空白字元常值。

適用於