使用微软的Ajax控件遇到的后台js提示语句不起作用的解决方案其一

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

<asp:UpdatePanel>
    <ContentTemplate>
                        
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnTeSe" />
    </Triggers>
</asp:UpdatePanel>

原先在使用这两个控件结合做的Ajax效果中遇到数据提交之后提升代码是这样的:

  this.Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript' defer>alert('添加成功');</script>",true);

后来改成这样就可以了:

ScriptManager.RegisterStartupScript(this, this.GetType(), DateTime.Now.ToString(), "alert('添加成功');", true);//这样可以在使用微软Ajax控件的时候可以做后台JS结果弹出效果!

原文地址:https://www.cnblogs.com/wgx0428/p/2768383.html