代码之家  ›  专栏  ›  技术社区  ›  Kimtho6

回发后运行javascript函数

  •  38
  • Kimtho6  · 技术社区  · 14 年前

    如何在更新面板内回发后运行javascript事件

    5 回复  |  直到 11 年前
        1
  •  25
  •   Paddy    14 年前

    可以使用ClientScriptManager在重新加载时调用函数:

    ClientScriptManager.RegisterStartupScript(this.GetType(), "AKey", "MyFunction();", true);
    

    http://msdn.microsoft.com/en-us/library/asz8zsxy.aspx

        2
  •  68
  •   m3kh    14 年前

    你可以使用 endRequest 事件 PageRequestManager .

    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>   
                <asp:Button runat="server" Text="Button" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
    <script type="text/javascript">
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(function (s, e) {
            alert('Postback!');
        });
    </script>
    
        3
  •  11
  •   Mina Gabriel    11 年前

    简单地

    <script type="text/javascript"> 
        function pageLoad() { 
    
      } 
    </script>
    
    <asp:ScriptManager runat="server" />
    
    <asp:UpdatePanel runat="server"> 
      <ContentTemplate> 
        <asp:Button runat="server" ID="Button1" /> 
        <asp:Literal runat="server" ID="TextBox1" /> 
     </ContentTemplate> 
    </asp:UpdatePanel>
    

    每次触发按钮1时,将继续调用pageLoad()。

    Read this by Dave Ward

        4
  •  4
  •   M.Mohammadi    11 年前

    试试这个:

    $.ajax({
    beforeSend: function(){
    // Handle the beforeSend event
    },
    complete: function(){
    // Handle the complete event
    }
    // ......
    });
    
        5
  •  1
  •   Tim B James    14 年前

    在更新面板中使用时,我将使用 ScriptManager.RegisterStartupScript