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

后端 未结 4 503
春和景丽
春和景丽 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条回答
  •  旧时难觅i
    2020-12-13 00:58

    Try using the ScriptManager to register the client script block, but give a unique title for each additional function call especially if it has unique parameters if you are using the same function but with different parameter values. If you use the add_load technique it should only be used when the page load is not a post back i.e. only called once after a page refresh or page load without a post back.

    try this instead: ScriptManager.RegisterClientScriptBlock(this, GetType(), "unique title", "alert('quick test');", true);

提交回复
热议问题