Sys.Application.add_load() vs. $(document).ready() vs. pageLoad()

后端 未结 4 504
春和景丽
春和景丽 2020-12-13 00:55

I have page that has some javascript that needs to run at page load. Said javascript needs to locate the client-side component of a ServerControl, which it does with $find(

4条回答
  •  情书的邮戳
    2020-12-13 01:08

    If you have control over the code-behind, you can register the JavaScript to run at startup via something like:

    this.Page.ClientScript.RegisterStartupScript(
        this.GetType(), 
        "StartupScript", 
        "Sys.Application.add_load(function() { functioncall(); });", 
        true);
    

    As long as your component has been loaded via Sys.Application.add_init() you should be fine...

提交回复
热议问题