ClientScript.RegisterStartupScript(this.GetType(), “LoadData“, “LoadData();”, true);
ClientScript = Page.ClientScript Property Gets a ClientScriptManager object used to manage, register, and add script to the page. [http://msdn2.microsoft.com/en-us/library/system.web.ui.page.clientscript.aspx]
RegisterStartupScript : Registers the startup script with the Page object using a type, a key, a script literal, and a Boolean value indicating whether to add script tags.
ClientScriptManager..::.RegisterStartupScript Method (Type, String, String, Boolean) [http://msdn2.microsoft.com/en-us/library/z9h4dk8y.aspx]
This script will run after Page-Load event so [MSDN says if run before page_load] . But working for me
LoadData = Key to register function
LoadData();=function to call
true = Add script tag or not [NOTE: Must do this to true] .
Now put anything in LoadData() function under .js file that’s it.
Another Problem and its solution:
var answer = confirm(“YES/NO?”);