Registerstartupscript (Key, script)
Registerclientscriptblock (Key, script)
Both methods are used to write scripts from the foreground to the background, and both of them accept two strings as input. The second parameter script is the client script to be inserted into the page, including the start and end tags of <SCRIPT>. The first parameter key is the unique identifier of the inserted client 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, becauseThe HTML elements to be modified must be defined before the script is run.. 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 by 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 isIt generally does not use custom controls in the document.