For project needs, use components developed by VC by other project teams, in the Web BackgroundCodeYou cannot access this component, so you have to use the background to call the front-end JavaScript to operate this component. I searched for it online and found that there are three methods to access the front-end code:
First, onclientclick (vs2003 does not support this method)
<Asp: button id = "button1" runat = "server" text = "button" onclientclick = "client_click ()" onclick = "button#click"/>
Client_click () is a JavaScript method.
Second, 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? ')
The third is what I think is the most flexible. clientscript. registerstartupscript
Example: stringbuilder sb = new stringbuilder ();
SB. append ("<script language = 'javascript '> ");
SB. append ("button2_onclick ('" + serverpath + "')");
SB. append ("</SCRIPT> ");
Clientscript. registerstartupscript (this. GetType (), "loadpicscript", SB. tostring ());
Fourth, write the script using the response. Write method.
For example, after you click the button, you must first operate the database. After the operation is complete, it is displayed that the operation is complete. You can write it in the last place you want to call.
Response. Write ("<SCRIPT type = 'text/JavaScript '> alert (); </SCRIPT> ");
This method has a defect that the user-defined functions in the script file cannot be called, and only internal functions can be called. The specific user-defined functions can only be called in response. write the function definition in write, such as response. write ("<SCRIPT type = 'text/JavaScript '> function myfun (){...} </SCRIPT> ");
Fifth, dynamically add scripts using the clientscript class
The usage is as follows: add code where you want to call a Javascript script function. Make sure that myfun has been defined in the script file.
Clientscript. registerstartupscript (clientscript. GetType (), "myscript", "<SCRIPT> myfun (); </SCRIPT> ");
This method is more convenient than response. Write. You can directly call the UDF in the script file.
You canProgramO (partition _ worker) O... is it easy to use?
Note the execution sequence: first execute the client and then execute the server