ASP.NET (BATA2) Tutorial immediately (C # version) -3

zhaozj2021-02-17  46

Processing server control events Each ASP.NET server control has the characteristics of an object model, including properties, methods, and events. ASP.NET developers can use this object model to dynamically modify the page, and interact with the page. The following example demonstrates how the ASP.NET page developer manifesses the text property of the control by handling the "ASP: Button Runat = Server> control.

C # Intro6.aspx

[Run] | [[Source Code] This simple example is functionally equal to the "INTRO3" example of the previous introduction. However, you can find how simple and clear this version of the server control! Use custom server-side control ASP.NET to provide 45 built-in server controls for use (see Web Forms Control Reference). In addition to using built-in ASP.NET controls, developers can also use the controls provided by third parties. The following example shows a simple calendar control (Calenda). This control is declared using the tab in the page. Note that <% register%> of the top of the page is registered with TagPRefix, using Namespace to explain the namespace of the control. ASP.NET Page Analyzer will use this name space to load an instance of Calendar's inter-Class Class at runtime.

C # Intro7.aspx

[Run] | [Source Code] In this example, the calendar control is designed to perform "Advanced Run" in Internet Explorer 5.5 or more, perform "low run" on other browsers. This monitoring of browser versions can be implemented in the built-in server control provided by ASP.NET. For IE5.5 or above, he generates DHTML output. The DHTML output does not require the server to reciprocate with the client. For other versions of browsers, this control generates a standard HTML3.2 document. In interaction, the client and server-side loop reciprocation are required. Important: When the page designer is writing code, it is not necessary to consider the browser when the browser is accessing the page, is "advanced run" or "low run". The Calendar control has encapsulated its ability to process different browser requests. List, data, and data binding ASP.NET built into a control of a table of data tables and lists, providing custom user interface drivers to implement requests for databases or other data sources. For example, the following example demonstrates how control uses the SQL database query language to implement data binding to the Book information collection.

C # INTRO8.ASPX [Run] | [Source Code] DataGrid control Use a traditional table interface to provide a simple and fast way of displaying data results. In addition, ASP.NET developers can also customize data from the DataList control and custom ItemTemplate template. Please see the example below

C # INTRO9.ASPX [Run] | [Source Code] Note that control allows the end user's accurate control list of each item's structure and appearance display (using the ItemPlate Template Properties). The control is automatically handled in two columns (the user can control the number of the number of the REPEATCOLUMNS attribute to control the number of columns), which provides an alternate display of the control. C # INTRO10.ASPX

[Run] | [Source Code] Note that the controls, data models, and page users here are the same as the previous example. The difference is that this example declares other templates in the code. Form Verification Control ASP.NET Web Forms page Frame provides a server verification control, which is easy to use, is used to check the error entered by the client form, and (if necessary) displays prompt information. Add server authentication controls in the page just like using other server controls. Different verification conditions have different verification controls, such as input range checks or mode matching, and more. Using the RequiredFieldValidator Verification Control ensures that users do not skip a field that should enter data. The following example demonstrates how to use the control in the page to verify the contents of the TextBox and DropdownList controls. C # intro11.aspx

[Run] | [Source Code] Note Verification Control also provides "Advanced Run" and "Low-level Run" support. High Version Browser Mode Performs (using Java scripts and DHTML) on server-side and clients, low-key browser mode only performs verification at the server side. The program mode in both cases is the same. Note that the ASP.NET page developer can check the page.isvalid property at any time at runtime to determine if all verification controls of the page are passed. This provides a simple method for business logic processing. For example, when the following example performs a database query for a specific classification, first execute the page.isvalid check.

C # intro12.aspx

[Run] | [Source Code] Web Forms Code Separation ASP.NET supports two ways to create dynamic pages. The first is that the page code is declared in the same .aspx file as the presentation in the previous example. Another method ---- people are familiar with code separation, allowing the page code to be more neat, separating the program code from HTML content, becoming a complete separate file. The following example demonstrates the use of code separation technology to write ASP.NET pages

C # INTRO13.ASPX [Run] | [Source Code] This chapter Split 1. ASP.NET provides a simple and powerful way to establish dynamic web user interface 2. ASP.NET Web Forms page can automatically adapt to any browser Customers (not required for script libraries or cookie) 3. ASP.NET Web Forms page provides syntax compatible with existing ASP pages 4. ASP.NET server control provides a simple way to encapsulate common functions. 5. ASP.NET provides 45 built-in server controls. Developers can also use the control provided by third parties. 6. ASP.NET Server controls automatically design advanced dynamic mode and low browser HTML mode 7. ASP.NET template can easily customize the appearance of the list server control to customize the appearance of page data display. 8. ASP.NET Verification Control can be easily verified by client or server data

转载请注明原文地址:https://www.9cbs.com/read-28466.html

New Post(0)