Chapter 8. Validation Controls

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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值