ASP.NET UpdatePanel and JavaScript functions
I would like to call JavaScript functions to show/hide a loading animation when a DropDownList is changed in an UpdatePanel.
Here is the DopDownList in an Updat开发者_C百科ePanel
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddl_size" runat="server" OnSelectedIndexChanged="ddl_size_SelectedIndexChanged" AutoPostBack="true">/asp:DropDownList>
...
Here are the JavaScript functions I want to call
function ShowLoadingAnimation() { ... }
function HideLoadingAnimation() { ... }
Do I use triggers? How do I use it? Thanks in advance.
You can use PageRequestManager
's beginRequest
and endRequest
handlers to show/hide animation. The implementation details are on Sys.WebForms.PageRequestManager beginRequest Event and Walkthrough: Animating ASP.NET UpdatePanel Controls MSDN pages.
Put this code in the JavaScript tag in your aspx page:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
function endRequestHandler() { yourJsFunction }
精彩评论