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 页框架调用,不打算直接在代码中调用。

继承者说明

可以在派生类中重写此方法,以指示是否允许在自定义控件中使用空格文本。

适用于