您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp.net >> 正文

asp+ 输入检查(e 文,转)

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-28 我要参与讨论

  来源 http://msdn.microsoft.com/library/default.asp?URL=/library/techart/PDC_userinput.htm

Introduction


Validating user input is a common scenario in a Web-based application. For production applications, developers often end up spending a lot more time and code on this task than we would like. In building the ASP+ page framework, it was important to try and make the task of validating input a lot easer than it has been in the past.

The Problem


In HTML 3.2, validating data is a difficult process. Each time you get a request, you need to write code to check the input and write any errors the user has made back to the page to help the user to correctly fill in the validation form. This is a taxing process for end users, developers, and servers alike.
DTHML and scripting languages improve things somewhat. It is possible to provide the user with immediate feedback on bad input and to prevent them from posting a page until it has been corrected. However, it can be almost impossible to guarantee that every user of your site has the required scripting environment. This usually means that if you want to use script to improve the interface of your pages, you have to write the same validation logic twice, once on the client, and again on the server, just in case the client code cannot be executed.

The Objective


Our objective with validation is as follows:
  • Provide components that can perform 90 percent or more of the typical input validation tasks for data entry pages.

  • Have these components perform rich script-based validation on modern browsers that can also effectively fall back to pure HTML 3.2 server-based validation, if required.

  • Provide a flexible API so that any validation tasks not covered by the components are easy to complete.

We visited a large number of real pages to determine the sort of scenarios these components needed to be able to handle. We wanted to dramatically reduce the amount of validation code needed for future applications.

The Solution—Overview


The validator controls are the main elements of the solution. A validator is a visual ASP+ control that checks a specific validity condition of another control. It generally appears to the user as a piece of text that displays or hides depending on whether the control it is checking is in error. It can also be an image, or can even be invisible and still do useful work. There are five types of validator controls that perform different types of checks.
Another element in our solution is the ValidationSummary control. Large data entry pages generally have an area where all errors are listed. The ValidationSummary automatically generates this content by gathering it up from validator controls on the page.
The final element is the Page object itself. It exposes the all-important "IsValid" prope

[1] [2] 下一页

在google里搜索更多asp+ 输入检查(e 文,转)

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明