Insert the client script from the ASP.NET server control (from the MSDN "website)

zhaozj2021-02-12  171

Introduction

Although from a technical perspective, all features of the Microsoft? ASP.NET server control can be executed on the server, but usually by adding client scripts can greatly enhance the availability of server controls. For example, an ASP.NET verifies that a web control can perform all validation checks on the server. However, for a high version browser, verifying the web control also sends a client script to verify on the client. That is to say, users of these browsers can get a better dynamic experience.

When developing an ASP.NET server control, you may wish to ask yourself, how to enhance availability by using the client script. Once you find a feasible solution, the other to do is to enhance the functionality of the server control to send it to the appropriate client script.

ASP.NET server controls can send two client scripts:

Client script block client HTML attribute

The client script is usually written in JavaScript, which is typically included when a specific client event occurs. The client HTML property provides a way to link client events with the client script. For example, the following HTML page contains a client script block, and a function named Doculick () is included in the script block. This page also contains a button (created via HTML element), this button is binded to the doclick () function. That is, as long as the user clicks the button, the client code in the doclick () function is started. In this example, a pop-up dialog is displayed (Figure 1).

Figure 1 is a screen snapshot of the HTML page when you click the Click ME! Button.

Figure 1: Click the pop-up dialog box when you click the Click ME! Button

For the client scripts in the above HTML page, there are several points worth noting. First, the client script includes the HTML annotation (

)in. The reason is because if the script is not placed in an HTML comment, the old browser that cannot identify the script will display the contents of the