I. frontend call background
1. the foreground calls the background variable (Note: The array variables cannot be obtained. You need to convert the separator into a string variable in the background, and then process the variable in the foreground as an array.)
The background page provides a global variable, which is assigned a value in page_load. The foreground uses <% = xxx %> to obtain the variable;
2. the foreground calls the background method (that is, Ajax. For details, see jquery. Bind the button to the click)
2. Call the foreground at the background
1. Use foreground variables in the background
Method 1: 1. the foreground uses static text controls to hide the field and write the JS variable value into it;
2. the backend uses request ["ID"] to obtain the value;
Method 2: cookie or session can be used
2. Use foreground functions in the background
(1) dynamically add scripts using the clientscript class(Better)
Foreground: function closewindow (){....}
Background: clientscript. registerstartupscript (clientscript. GetType (), "myscript", "<SCRIPT> closewindow (); </SCRIPT> ");
(2) onclientclick
<Asp: button id = "button1" runat = "server" text = "button" onclientclick = "client_click ()" onclick = "button#click"/>
Client_click () is a JavaScript method,Execute client_click ();
(3) button1.attributes. Add ("onclick", "Return client_click ()");
"Client_click ()" is a foreground method that can be replaced with a general script such as retrun confirm ('Are you sure you want to delete it? ')