Reputation: 10672
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
Upvotes: 2
Views: 1138
Reputation: 17844
string 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
});
Upvotes: 1
Reputation: 35264
You can use this,
Page.ClientScript.RegisterStartupScript(Page.GetType(), "script",
"urfunction()", true);
Upvotes: 1
Reputation: 11397
try with RegisterStartupScript
E.g:
RegisterStartupScript("Msg1", "<script language='javascript'> alert('Hello World') </script>");
Upvotes: 2