There are many ways to add script block to our asp.net pages. This is a very simple problem until we had got a complex project with custom controls, partial page rendering, updatepanels and dynamically loaded controls.
We have to add script blocks different ways if we asynchrony post backs or full page post backs.
The other problem is when the script block don’t have to load at the first page load, it depends on some logic dynamically.
After many trying I use this solution since about half year and it works at any case.
The simple and easy to use source code is:
After registering into web.config, we can use it easily everywhere on our program: