.net ajax 注册脚本提示信息


今天做一个程序,用到了.net的ajax,需要在点击按钮之后注册脚本弹出提示或者警告信息

.aspx页面中使用一个UpdatePanel

<asp:ScriptManager runat="server" ID="scriptManager" EnablePartialRendering="true"></asp:ScriptManager>
        
<asp:UpdatePanel ID="gvUpdate" runat="server" UpdateMode="conditional">
        
<ContentTemplate>
     
        
</ContentTemplate>
        
</asp:UpdatePanel>

 

.cs 添加方法 ShowMessage

    void ShowMessage(string txt)
    
{
        System.Web.UI.ScriptManager.RegisterStartupScript(
thisthis.GetType(), "msg""alert('" + txt + "');"true);
    }

 

然后在事件中调用ShowMessage方法,就OK了

如果页面中使用多个UpdatePanel控件,我们想对每个UpdatePanel调用不同的ShowMessage 那么
我们需要把页面中UpdatePanel的UpdateMode属性设为为 contitional

UpdateMode="conditional"


然后把脚本注册事件中的 this 改为相应的UpdatePanel 就可以相应对应UpdatePanel的事件了

posted on 2007-12-03 14:42  jerreychen  阅读(477)  评论(0编辑  收藏  举报

导航