ASP. NET design controls purify Website Languages (1)

Source: Internet
Author: User

■ Dongfang luxiao ■ yesky

  I. Overview

Consider this situation: you write an application for a web site. The function is to accept user input and save the input permanently, for example, to the database, in addition, user input must be displayed on the website. For example, a forum is a typical example.

If user sources are complex, you must consider how to prevent users from submitting and posting offensive (or pornographic or vulgar) content. Possible solutions include:

(1) restrict the user group to a closed user group, that is, users must register/log on before using the functions of the program. In this way, since each submitted content can be traced to the submitter, the possibility of users cracking website Rules is much lower. If a user does something that shouldn't be done, you can verify the user's identity and handle it accordingly.

(2) The Administrator reviews the content submitted by users on the website. In many cases, this method may not work due to limited human resources.

(3) prohibit users from submitting aggressive content. This is the most ideal solution to solve the problem in the origin. But how should we implement it?

The solution described in this article is based on a composite control and uses an XML file to define offensive words. We will use VB. NET to compile this composite control, and use a common text editor and command line compiler (vbc) to build the entire project.

Before writing controls, let's briefly review the concept of controls in ASP. NET. All the controls shown in this article are server controls that run on the server and send HTML code to the client. To understand the classification of controls, you can observe whether the controls are embedded on the web form page (based on-demand compilation) or pre-compiled. Microsoft defines the following ASP. NET Server controls: HTML server controls, web server controls, verification controls, and user controls.

Readers of the first three controls should already be familiar with them. For developers, they are the simplest control types and have been compiled by Microsoft in ASP. NET. User Controls are different. A user control is a. ASPX page in the form of a. ascx page. Other. aspx pages can call the functions of a user control through registration and instantiation. This is a highly anticipated server-side control, for ASP/asp. NET developers, it represents a major improvement. In particular, the language for writing controls now fully supports object-oriented technology.

ASP. NET user controls consist of one or more server controls and static HTML elements. They can contain additional code. Each user control encapsulates a set of specific functions. The user control can be obtained by simply extending the existing Server Control (control group). For example, a graphical control with the rotation function saves the calendar control of the date in the text box.

1 2 3 next page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.