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

傳回

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.

適用於