Both methods are used to write scripts from the background to the foreground, and both of them accept two strings as input. The first parameter key is the unique identifier of the inserted client script, and the second parameter script is the client script to be inserted to the page, including the start and end tags of the <SCRIPT>.
The only difference between the two methods is that the script block is sent from "where. Registerclientscriptblock () sends the script block at the beginning of the web form (followed by the <form runat = "server"> identifier), while registerstartupscript () the script block is sent at the end of the web form (before the </form> identifier.
Registerstartupscript () is used to add the script block to run after the page is loaded. The script block added in this way is located at the end of the web form, because the HTML elements to be modified must be defined before the script runs. That is, if you want to use a client script to set the focus to the text box, make sure that the HTML mark of the text box is before the script that sets the focus of the text box.
The registerclientscriptblock () method is used to execute scripts in response to client events.Code. The script block sent using this method is located at the beginning of the web page, because this method does not require that the script block be placed after all HTML elements, that is, it generally does not use custom controls in the document.