Why can't we write a JavaScript code using Response.Write(".....") to serve the same purpose as RegisterStartupScript()?
A:
RegisterStartupScript() will place the HTML in the correct place in your HTML (usually at the end, before the </body>
tag.
Philippe Leybaert
2009-06-03 07:34:26
A:
RegisterStartupScript() will correctly wireup you script when it will be loaded from UpdatePanel. By default, code in UpdatePanel update is not treated as script - this should be done manually or by using RegisterStartupScript().
Ivan Suhinin
2009-06-03 10:37:42
But what will happen if I use ICallback... -like interfaces to achieve the same goal as UpdatePanel?What would be the role of RegisterStartupScript() then?
2009-06-03 11:56:16
Looks like it will be same as Response.Write("...") then. I've disassembled this method in Resharper and seems like it does nothing but registers script for UpdatePanel and generates correct <script> tags. If you will not use UpdatePanel you'll not get any actual benefit.
Ivan Suhinin
2009-06-05 08:28:45