Second, the development of composite control controls should check if the content submitted by the user contains "Attack" words, the aggressive word is defined by an XML file, the structure of the XML file is as follows:
Xml version = "1.0"? Encoding = "GB2312">
The composite controls of this article contain three ASP.NET server controls: a TextBox control, a Label control, and a Button control. When the user clicks on the Button control, Composite checks whether the text submitted by the user contains the words specified in the XML file (the default name of the XML file is BAD_WORDS.XML, defined by a custom property) and throws a custom event. In addition, the Composite control also exposes a Text property of its Label child control to top properties.
Composite controls can optionally expose sub-controls into properties, or selectively select the properties and events of sub-controls as top attributes and events. When the composite control is integrated from the properties of the child control, it is usually just simply entrusting the sub-control operation, as shown in the following example:
// delegating operation to label the object, the object is a label System.Web.UI.WebControls.Label instance // Public Property Text () As StringGetEnsureChildControls () Return label.TextEnd GetSetEnsureChildControls () label.Text = valueEnd SetEnd Property
We need a text input box to allow the user to enter content, a button to submit a form, and a text tag for feedback to user feedback. Let's take a look at the code of the web form, the composite control is instantiated here:
[Composite.ASPX]
<% @ Page language = "VB" debug = "false" trace = "false"%> <% @ register tagprefix = "custom" namespace = "customtrols" assembly = "CustomControls"%>