开发者

How to call a JavaScript function from C# code

开发者 https://www.devze.com 2023-01-11 15:31 出处:网络
I need to call a jav开发者_如何学编程ascript function from C# code after page Load, or is it there any way that I can do this on .aspx page itself??

I need to call a jav开发者_如何学编程ascript 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>");


You can use this,

Page.ClientScript.RegisterStartupScript(Page.GetType(), "script", 
   "urfunction()", true);


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
});
0

精彩评论

暂无评论...
验证码 换一张
取 消