Microsoft's Ajax controls are quite powerful.
-- Dynamic Registration in the background
Scriptmanager1.registerasyncpostbackcontrol (slider1 );
-- Use controls on the page
<Asp: updatepanel id = "updatepanelmsg" runat = "server">
<Triggers>
// Let the control in updatepanel return, that is, do not partially refresh
<Asp: postbacktrigger controlid = "btdown"/>
</Triggers>
<Triggers>
// Make the controls outside updatepanel have a partial refresh function
<Asp: asyncpostbacktrigger
Controlid = "btnchangetime" // the ID of the control that implements situation refresh
Eventname = "click"/>
// Event name for refreshing the situation. Note that it is not the method name
</Triggers>
</ASP: updatepanel>
This simple two-sentence setting completes a great deal of functionality, which is really easy to use. The following is an example of calling a custom JS function when Ajax is executed.
<% @ Page Language = "C #" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat = "server"> protected void button#click (Object sender, eventargs E) {system. threading. thread. sleep (1000); label1.text = datetime. now. tostring ();} protected void panel1trigger_click (Object sender, eventargs e) {system. threading. thread. sleep (1000); label1.text = datet Ime. now. tostring () + "-Trigger ";} </SCRIPT> <HTML xmlns = "http://www.w3.org/1999/xhtml">