// 将操作委托给标签对象,标签对象是一个 // System.Web.UI.WebControls.Label的实例 Public Property Text() As String Get EnsureChildControls() Return label.Text End Get Set EnsureChildControls() label.Text = value End Set End Property
<%@ page language="vb" debug="false" trace="false" %> <%@ Register TagPrefix="Custom" Namespace="CustomControls" Assembly = "CustomControls" %> <html> <script language="VB" runat=server> Private Sub CheckText(sender As Object, e As CheckEventArgs) If e.Match = false Then Composite.Text = "<h2>发布内容请遵守本站规则!不得发布攻击性言辞!</h2>" Else Composite.Text = "你提交的内容已通过检查!" End If End Sub </script>
Namespace CustomControls Public Class Composite Inherits Control Implements INamingContainer Private _filename As String = "bad_words.xml" Private label As Label Private box1 As TextBox
Public Property filename() As String Get Return _filename End Get Set _filename = value End Set End Property
' 以用户提交的文本内容为输入参数。如果用户提交的内容包含攻击性言辞, ' 则返回修改后的版本, ' 否则,直接返回原始的文本。 Public Function CheckStrin