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.

适用于