感觉这种最好用:

public void showMessage(string str_Message)
{
ClientScript.RegisterStartupScript(this.GetType(), "结果", "alert('" + str_Message + "');", true);
// Define the name and type of the client scripts on the page. String csname1 = "PopupScript";
String csname2 = "ButtonClickScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert('Hello World');";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
{
System.Text.StringBuilder cstext2 = new System.Text.StringBuilder();
cstext2.Append("<script type=\"text/javascript\"> function DoClick() {");
cstext2.Append("Form1.Message.value='Text from client script.'} </");
cstext2.Append("script>");
cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
} //ClientScript.RegisterClientScriptBlock(this.GetType(), "tishi", "<script type='text/javascript'>alert('你所查询的数据不存在!');</script>"); //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "tishi","<script type='text/javascript'>alert('你所查询的数据不存在!');</script>");
//ClientScriptManager scriptManager =((System.Web.UI.Page)System.Web.HttpContext.Current.Handler).ClientScript;
//scriptManager.RegisterStartupScript(typeof(string), "", "alert('str_Message');", true);
//scriptManager.RegisterStartupScript(typeof(string), "", "alert('str_Message');self.location='redirect'", true);
}
 
 
原文转载:http://www.cnblogs.com/luqian5588/p/3228225.html
 
 
 

1.后台弹出提示信息方法

Response.Write("<scripttype="text/javascript">alert('你所查询的数据不存在!');</script>");

//弹出提示信息,但页面空白 Page.RegisterClientScriptBlock("tishi", "<scripttype="text/javascript">alert('你所查询的数据不存在');</script>");

//弹出提示信息,但页面空白 Page.RegisterStartupScript("tishi", "<scripttype="text/javascript">alert('你所查询的数据不存在');</script>");//已过期,

//弹出提示信息,页面不空白 ClientScript.RegisterClientScriptBlock(this.GetType(), "tishi","<script type="text/javascript">alert('你所查询的数据不存在!');</script>");

//弹出提示信息,但页面空白 ClientScript.RegisterStartupScript(this.GetType(), "tishi","<script type="text/javascript">alert('你所查询的数据不存在!');

</script>");

//弹出提示信息,页面不空白
//在vs2005中 需要引入System.Web.Extensions.dll ScriptManager.RegisterClientScriptBlock(this.btnTiShi, typeof(Button),"tishi", "alert('你所查询的数据不存在!');", true);

//弹出提示信息,但页面空白 ScriptManager.RegisterClientScriptBlock(this, this.GetType(),"tishi", "alert('你所查询的数据不存在!');", true);

//弹出提示信息,但页面空白,this表示page ScriptManager.RegisterStartupScript(this.btnTiShi, typeof(Button),"tishi", "alert('你所查询的数据不存在!');", true);

//弹出提示信息,页面不空白 ScriptManager.RegisterStartupScript(Page,typeof(Page), "tishi","alert('你所查询的数据不存在!');", true);

//弹出提示信息,页面不空白 ScriptManager.RegisterStartupScript(this, typeof(_Default), "tishi",script, true);

//弹出提示信息,页面不空白,this表示page

//后台获得confirm返回值,并有选择的执行语句块 C#端: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnTiShi.Attributes.Add("onclick","tishi()"); } }

protected voidbtnTiShi_Click(object sender, EventArgs e) { if (this.hidevalue.Value == "1") { Response.Write("success"); } else { Response.Write("failue"); } }

JS端: <script type="text/javascript"> function tishi() { if(confirm('你确定要删除吗?')) { document.getElementByIdx_x('hidevalue').value='1'; //window.location.href=window.location.href; } else { document.getElementByIdx_x('hidevalue').value='0'; } } </script>

【转载】asp.net 后台弹出提示框的更多相关文章

  1. asp.net 后台弹出提示框

    1.后台弹出提示信息方法 Response.Write("<scripttype="text/javascript">alert('你所查询的数据不存在!') ...

  2. [转] 在Asp.net前台和后台弹出提示框

    一.在前台弹出提示框 1.点击"A"标记或者"控件按钮"弹出提示框 <asp:LinkButton ID="lbtnDel" runa ...

  3. 【转】在Asp.net前台和后台弹出提示框

    源地址:http://blog.sina.com.cn/s/blog_5200dd680100mkk0.html

  4. C# ASP response.write()弹出提示框后页面布局被打乱

    发现在使用了response.write后样式发生了变化,位置和字体都不正确.Response.Write("<script>alert(')</script>&qu ...

  5. SilverLight 页面后台方法XX.xaml.cs 创建JS,调用JS ,弹出提示框

    1.Invoke和InvokeSelf [c-sharp] view plaincopy public partial class CreateJSDemo : UserControl { publi ...

  6. 每日学习心得:CustomValidator验证控件验证用户输入的字符长度、Linq 多字段分组统计、ASP.NET后台弹出confirm对话框,然后点击确定,执行一段代码

    2013-9-15 1.    CustomValidator验证控件验证用户输入的字符长度 在实际的开发中通常会遇到验证用户输入的字符长度的问题,通常的情况下,可以写一个js的脚本或者函数,在ASP ...

  7. iOS bug 之 H5 页面没有弹出提示框

    描述:在安卓上有提示框,但是在iOS上没有提示框. step 1: 失误,是我没有在正确的位置设置网址. step 2: 修改之后,测试页能弹出提示框,但是正式的页面没有提示框. step 3: 我输 ...

  8. C#自动关闭弹出提示框

    自动关闭弹出提示框(用一个小窗体显示提示信息):例如在一个form窗体中弹出自动关闭的提示框1.首先创建一个弹出提示信息的窗体 AutoCloseMassageBox,在里面拖一个lable控件,去掉 ...

  9. android标题栏上面弹出提示框(二) PopupWindow实现,带动画效果

    需求:上次用TextView写了一个从标题栏下面弹出的提示框.android标题栏下面弹出提示框(一) TextView实现,带动画效果,  总在找事情做的产品经理又提出了奇葩的需求.之前在通知栏显示 ...

随机推荐

  1. 安卓解析XML文件

    安卓解析XML文件 主要有三种方式:DOM解析.SAX解析.PULL解析 其中: DOM解析为等XMl文件全部加载后,然后根据需要解析的内容解析出所需的内容数据. SAX解析为从XML文件中执行一行, ...

  2. msp430入门学习42

    msp430的其他十 msp430入门学习

  3. CodeChef - LEMOVIE Little Elephant and Movies

    Read problems statements in Mandarin Chineseand Russian. Little Elephant from Zoo of Lviv likes to w ...

  4. win7配置java环境变量

    http://jingyan.baidu.com/article/9f63fb91d87fb0c8400f0e93.html 安装JDK,从Oracel官方网站上下载,也可以通过搜索,进入链接.下载完 ...

  5. 校园网、教育网 如何纯粹访问 IPv6 网站避免收费

    我国校园网有可靠的 IPv6 网络环境,速度非常快.稳定,并且大多数高校在网络流量计费时不会限制 IPv6 的流量,也就是免费的.然而访问 IPv4 商业网络时,则会收费,并且连接的可靠性一般.可幸的 ...

  6. JavaScript对列表节点的操作:删除指定节点、删除最后一个节点、删除第一个节点、删除所有节点、增加节点

    使用菜鸟的运行环境直接测试:http://www.runoob.com/try/try.php?filename=tryjs_events <!DOCTYPE html> <html ...

  7. sqlmap sql 注入攻击

  8. android 内部文件读取

    Android 文件管理方法 Android使用的是基于Linux的文件系统,对于文件的訪问和管理是通过权限设置来限制的. 在Linux系统中,文件权限分别描写叙述了创建者.同组用户和其它用户对文件的 ...

  9. Android命令行下蓝牙使用

    注意:此部分仅仅适用于broadcom 系列蓝牙芯片,比如RK903, AP6xxx 系列 通过su 命令切换到root 用户 1.先确认RFKILL 驱动已经载入 ls /sys/class/rfk ...

  10. linux 标准i2c接口(一)

    一:I2C设备操作方式: 1.  应用程序操作法:i2c的设备的驱动可以直接利用linux内核提供的i2c-dev.c文件提供的ioctl函数接口在应用层实现对i2c设备的读写,但是在应用层使用ioc ...