tailieunhanh - Professional ASP.NET 3.5 in C# and Visual Basic Part 26

Professional in C# and Visual Basic Part 26. 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 associates itself with one of the form elements on the page. In this case you need only a single CompareValidator control on the page because a single comparison is made. In this example you are making a comparison between the value of TextBox2 and that of TextBox1. Therefore you use the ControlToCompare property. This specifies what value is compared to TextBox2. In this case the value is TextBox1. It s as simple as that. If the two text boxes do not match after the page is posted by the end user the value of the Text property from the CompareValidator control is displayed in the browser. An example of this is shown in Figure 4-2. Figure 4-2 Validating Against Constants Besides being able to validate values against values in other controls you can also use the Compare Validator control to make comparisons against constants of specific data types. For example suppose you have a text box on your registration form that asks for the age of the user. In most cases you want to get back an actual number and not something such as aa or bb as a value. Listing 4-9 shows you how to ensure that you get back an actual number. Listing 4-9 Using the CompareValidator to validate against constants Age asp TextBox ID TextBox1 Runat server MaxLength 3 asp TextBox nbsp asp CompareValidator ID CompareValidator1 Runat server Text You must enter a number ControlToValidate TextBox1 Type Integer Operator DataTypeCheck asp CompareValidator 204 Chapter 4 Validation Server Controls In this example the end user is required to enter in a number into the text box. If she attempts to bypass the validation by entering a fake value that contains anything other than a number the page is identified as invalid and the CompareValidator control displays the value of the Text property. To specify the data types that you want to use in these comparisons you simply use the Type property. The Type property can take the following values Currency Date Double Integer .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.