The problem that was first encountered when JavaScript was used to transform the image module was discovered by accident. At that time, the problem was that the elements on the document could not be found. The reason is that"
We have introduced two different methods for embedding JavaScript Functions into ASP. NET pages. What is the difference between them? The main difference is that the registerstartupscript method embeds JavaScript at the bottom of the ASP. NET page, just before the close element </form>. The registerclientscriptblock method embeds Javascript into the end of the <form> element that is enabled on the page. So what's the difference? As we will see, this is a big difference.
Here is an example. Here is how to focus on a text box on the page when the page is loaded to a browser-Use Visual Basic that uses the registerstartupscript method:
Page. clientscript. registerstartupscript (Me. GetType (), "testing", _ "document. Forms [0] ['textbox1']. Focus ();", true)
When the browser runs at the bottom of the page and executes this small JavaScript code, a text box on the page is generated and placed on the page. Therefore, this method runs normally. However, if you do not follow the above method, write the following:Code(Use the registerclientscriptblock method ):
Page. clientscript. registerclientscriptblock (Me. GetType (), "testing", _ "document. Forms [0] ['textbox1']. Focus ();", true)
The text box control does not get the focus and generates a javascript error on the page.
The error occurs because the browser encounters JavaScript before the text box appears on the page. Therefore, textbox1 cannot be found in Javascript ."
If you use scripts in Asp.net, remember to note the difference.