C# 是否可以在UpdatePanel中重新执行javascript?

C# 是否可以在UpdatePanel中重新执行javascript?,c#,asp.net,ajax,updatepanel,C#,Asp.net,Ajax,Updatepanel,我有以下资料: <asp:UpdatePanel ID="upd" runat="server"> <ContentTemplate> <script> alert("execute again"); </script> <asp:LinkButton ID="go" runat="server" Text="Exec JS" /> </ContentTemplate>

我有以下资料:

<asp:UpdatePanel ID="upd" runat="server">
    <ContentTemplate>

        <script> alert("execute again"); </script>

        <asp:LinkButton ID="go" runat="server" Text="Exec JS" />

    </ContentTemplate>
</asp:UpdatePanel>

警报(“再次执行”);
第一次呈现页面时,脚本将被执行。如果我单击按钮导致回发,它将不会再次执行


有没有办法让它再次执行脚本?

由于ASP只是推送原始数据,而不是实际执行它,您可能需要使用ScriptManager的RegisterStartupScript方法以编程方式注入脚本,以便在部分回发后加载

编辑
更直接地说,尝试在中查找UpdatePanel。e、 g.

哟!有一种简单的方法可以让JavaScript再次运行。将javascript放在页面的HeadContent部分:

<script> 

function BindIt()
{
    alert("execute again"); 
}

</script>

函数BindIt()
{
警报(“再次执行”);
}
然后在“更新”面板内的页面上添加一部分,其中包含对为javascript创建的函数的调用:

            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                <script type="text/javascript">
                    Sys.Application.add_load(BindIt);
                </script>
...

系统应用程序添加加载(BindIt);
...

在我正在进行的一个项目中,我希望页面上的所有javascript都能再次运行,所以我将其全部放入一个大型BindIt风格的函数中。我花了一段时间才弄明白这一点,我尝试了许多方法来实现这一点,但这是我唯一能够让jquery使用updatepanels的方法。如果JavaScript与jquery相关,下面的链接肯定会有帮助:


我个人使用了本文中提到的第二种方法,它对我很有效。

是的!那是我用过的同一篇文章。:)谢谢你,它在我的SharePoint 2010 FBA应用程序中为我工作