I need to call a javascript function from C# code after page Load, or is it there any way that I can do this on .aspx page itself??
Thanks
I need to call a javascript function from C# code after page Load, or is it there any way that I can do this on .aspx page itself??
Thanks
try with RegisterStartupScript
E.g:
RegisterStartupScript("Msg1", "<script language='javascript'> alert('Hello World') </script>");
ClientScriptManager.RegisterStartupScript method. Looks like it's the same as calling Page.ClientScript.RegisterStartupScript(Page, Page.GetType(), "key", "MyFunc();", true);, but much shorter, and more readablestring script = "..." // your script here without <script> tags
ClientScript.ClientScript.RegisterStartupScript(GetType(), "key", script, true)
Also if you want to use it directly from the .aspx you can use jquery
$(document).ready( function() {
//... your script here
});
RegisterClientScript with RegisterClientScriptBlock, since no RegisterClientScript method exists