服务器端弹出alert对话框(Ajax和非Ajax两种方式)

ContractedBlock.gif ExpandedBlockStart.gif Code
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;

namespace JCBTMS.BLL.Admin
ExpandedBlockStart.gifContractedBlock.gif
{
    
public class MsgBox
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
        
/// 服务器端弹出alert对话框(用于非Ajax方式)
        
/// </summary>
        
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>    

        public static void Alert(string str_Message)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            ClientScriptManager scriptManager 
= ((Page)System.Web.HttpContext.Current.Handler).ClientScript;
            scriptManager.RegisterStartupScript(
typeof(string), DateTime.Now.ToString() + DateTime.Now.Millisecond.ToString(), "alert('" + str_Message + "');"true);
        }


ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
        
/// 服务器端弹出alert对话框(用于AJAX方式)
        
/// </summary>
        
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>    

        public static void AlertAjax(string str_Message)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            ScriptManager.RegisterClientScriptBlock((Page)System.Web.HttpContext.Current.Handler, 
typeof(string), DateTime.Now.ToString() + DateTime.Now.Millisecond.ToString(), "alert('" + str_Message + "');"true);
        }

    }

}

使用Alert方法需要添加System.Web引用;而使用AlertAjax方法需要添加System.Web.Extensions引用,同时该应用程序目标框架要设置为.NET Framework 3.5。

posted on 2009-07-16 17:24 ms_dos 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/nine425/archive/2009/07/16/1525051.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值