Running script after Update panel AJAX asp.net

前端 未结 2 1937
误落风尘
误落风尘 2020-12-31 05:46

I am running an ajax update panel in my website. The update panel returns some new controls. I would like to set some JavaScript for the controls after they are returned fro

相关标签:
2条回答
  • 2020-12-31 06:01

    tie into the MSAjax Event

    function pageLoad(){ } 
    

    this will fire every time the update panel refreshes.. you can do your rebinding / new bindings there

    ...and yes, that's all you need to do, put that on the page and it will fire.

    Update:: [looks like i had the function named incorrectly ( i think it would still work tho) ] it's really that simple if you have a script manager on the page..

    <script> 
       ///<summary>
       ///  This will fire on initial page load, 
       ///  and all subsequent partial page updates made 
       ///  by any update panel on the page
       ///</summary>
       function pageLoad(){ alert('page loaded!') }  
    </script>
    

    http://www.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx

    Archived:

    https://web.archive.org/web/20160802132945/http://ajax.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx

    0 讨论(0)
  • 2020-12-31 06:03

    You could use a Timer with a function that checks if the controls exists every few hundred ms. Once it detects them, apply your script and end the timer.

    0 讨论(0)
提交回复
热议问题