| many users call client functions on the server, that is, they call the script functions defined in JavaScript scripts in ASP. After research, we found some stubborn methods. 1. use response. write method write script for example, after you click the button, you must first operate the database, and then the operation is complete, you can write response. write (" "); This method has a defect that it cannot call the custom functions in the script file. It can only call internal functions. The specific call of custom functions can only be in response. write the function definition in write, such as response. write (" "); 2. use the clientscript class to dynamically add scripts usage: Add Code . Make sure that myfun has been defined in the script file. clientscript. registerstartupscript (clientscript. getType (), "myscript", ""); compared to response. write is more convenient. You can directly call the custom functions in the script file. 3. ordinary add control attributes for common buttons: button1.attributes. add ("onclick", "myfun ();"); the value can only be added in onload or during onload initialization. In addition, the script function is executed first, and the execution sequence cannot be changed. note: In all the above methods, the background Code cannot convert the code on the current page, such as redirect, put the page-turning code in the script |