Chapter 8. Validation Controls

王朝asp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

Chapter 8. Validation Controls

OBJECTIVES

Investigate the validation controls provided by ASP.NET

Create Web forms that validate data

Before ASP.NET, validating the data users entered onto a Web page either

required complex script code that ran in the client browser or a roundtrip

to the server to run code on the server side to determine the validity of

the data. Things are a lot simpler in ASP.NET. Here, you'll find a series

of controls梩he validation controls梩hat make validating data on either the

client or server side much simpler.

If your users view your page using an "up-level" browser (that is, IE 4.0

or higher), ASP.NET can render script so that the browser can perform

client-side validation. If not, ASP.NET can only validate the controls'

data on the server. Even if your users browse to the page using an up-level

browser, ASP.NET will always perform a final server-side validation,

ensuring that no clever hacker can bypass the validation by replacing code

on the client side. Performing client-side validation not only simplifies

your development, but also makes the runtime experience more interactive梱our

users see validation warnings immediately upon leaving a control that

handles invalid data.

To add validation support to any control, add an associated validation

control to the page and set the properties of the control to indicate the

following:

The control that needs to be validated.

The set of acceptable values. This information differs depending on the

type of validation control you're using.

The text to be displayed within the validation control if the associated

control's value isn't valid.

The text to be displayed in a validation summary.

You can place the validation control at any location on the page, but most

people place the control adjacent to the data-entry control it's validating.

In this chapter, you'll learn about the different types of validation

controls, and you'll see examples of working with each.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航