Professional ASP.NET 3.5 in C# and Visual Basic Part 27

Professional in C# and Visual Basic Part 27. Building on the revolutionary release, adds several key new developer features including AJAX, LINQ, and a new CSS designer in Visual Web Developer 2008. The dramatic reduction in code that developers realized from the more than 50 new server controls in now allows developers the time to make their applications more interactive with AJAX, to work with data in their preferred language with LINQ, and to build visually attractive and consistent standards-based sites with CSS. . | Chapter 4 Validation Server Controls F CustomValidator - Windows Internet Explorer 1 1 a WÏ j j jg http localhost 60737 Validatk n Defaultaspx X Goocte P 4 CustomValidator a a Page Tools Number 34 Number must be divisible by 5 -j Button Done Internet Protected Mode Off Figure 4-7 If you create your own server-side validations you can make them as complex as your applications require. For instance using the CustomValidator for server-side validations is something you do if you want to check the user s input against dynamic values coming from XML files databases or elsewhere. For an example of using the CustomValidator control for some custom server-side validation you can work with the same example as you did when creating the client-side validation. Now create a server-side check that makes sure a user-input number is divisible by 5. This is illustrated in Listing 4-15. Listing 4-15 Using the CustomValidator control to perform server-side validations VB @ Page Language VB script runat server Protected Sub Button1_Click ByVal sender As Object ByVal e As If Then VALID ENTRY End If End Sub Sub ValidateNumber sender As Object args As ServerValidateEventArgs Try Dim num As Integer num mod 5 0 Catch ex As Exception False End Try End Sub script html xmlns http 1999 xhtml head runat server title CustomValidator title head body form id form1 runat server 214 Chapter 4 Validation Server Controls div p Number asp TextBox ID TextBox1 Runat server asp TextBox nbsp asp CustomValidator ID CustomValidator1 Runat server ControlToValidate TextBox1 Text Number must be divisible by 5 OnServerValidate ValidateNumber asp CustomValidator p p asp Button ID Button1 OnClick Button1_Click Runat server Text Button asp Button p p asp Label ID Label1 Runat server asp Label p div form body html C @ Page Language C script runat server protected void Button1_Click Object sender EventArgs e if .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.