ControlBuilder.AllowWhitespaceLiterals 方法

定義

判斷控制項的開頭和結尾標記之間的內容是否允許空白字元常值。Determines whether white space literals are permitted in the content between a control's opening and closing tags. 此方法由 ASP.NET 網頁架構呼叫。This method is called by the ASP.NET page framework.

public:
 virtual bool AllowWhitespaceLiterals();
public virtual bool AllowWhitespaceLiterals ();
abstract member AllowWhitespaceLiterals : unit -> bool
override this.AllowWhitespaceLiterals : unit -> bool
Public Overridable Function AllowWhitespaceLiterals () As Boolean

傳回

永遠會傳回 trueAlways returns 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 方法是用來判斷控制項的開頭和結束記號之間的內容是否允許空白字元常值。The AllowWhitespaceLiterals method is used to determine whether white space literals are permitted in the content between the opening and closing tags of a control. 當這個方法傳回 false時,在頁面剖析器處理內容之前,會先從內容中修剪空白字元的常值。When this method returns false, the white space literals are trimmed from the content before the content is processed by the page parser. 當這個方法傳回 true時,不會移除空白字元常值。When this method returns true, the white space literals not removed.

在剖析期間,ASP.NET 網頁架構會呼叫這個方法,而不是直接在您的程式碼中呼叫。This method is called by the ASP.NET page framework during parsing and is not intended to be called directly in you code.

給繼承者的注意事項

您可以在衍生類別中覆寫這個方法,以指出您的自訂控制項中是否允許空白字元常值。You can override this method in your derived class to indicate whether white space literals are permitted in your custom control.

適用於