感觉这种最好用:

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. spring-基于注解的配置

    基于注解的配置 除了采用采用xml来配置bean之外,也可以采用注解的方式来定义,注册,加载bean. 注解的方式在spring中默认时不开启的,所以需要在xml文件中进行配置启用 注解的启动方式有下 ...

  2. 省赛i题/求1~n内所有数对(x,y),满足最大公约数是质数的对数

    求1~n内所有数对(x,y),gcd(x,y)=质数,的对数. 思路:用f[n]求出,含n的对数,最后用sum[n]求和. 对于gcd(x,y)=a(设x<=y,a是质数),则必有gcd(x/a ...

  3. python--输出自己需要的字符串连接的的方式

    python中有很多字符串连接方式,今天在写代码,顺便总结一下,从最原始的字符串连接方式到字符串列表连接,大家感受下: 最原始的字符串连接方式:str1 + str2 python 新字符串连接语法: ...

  4. android Containers控件

    1.RadioGroup 一组单选框容器 2.ListView 3.GridView 4.ExpandableListView 可折叠列表 5.ScrollView 上下滚动条 6.Horizonta ...

  5. python 获取时间 存入文件

    1读文件: file_path_name = '/home/robot/bzrobot_ws/src/bzrobot/bzrobot_comm/led_show_data/'+file_name+'. ...

  6. 洛谷 P1503鬼子进村

    题目背景 小卡正在新家的客厅中看电视.电视里正在播放放了千八百次依旧重播的<亮剑>,剧中李云龙带领的独立团在一个县城遇到了一个鬼子小队,于是独立团与鬼子展开游击战. 题目描述 描述 县城里 ...

  7. spark hbase

    1 配置 1.1 开发环境: HBase:hbase-1.0.0-cdh5.4.5.tar.gz Hadoop:hadoop-2.6.0-cdh5.4.5.tar.gz ZooKeeper:zooke ...

  8. Google代码风格配置文件(Java)(IDEA/Eclipse)

    官网:http://www.cnblogs.com/EasonJim/p/7837474.html 下载: 安装: IDEA/Eclipse导入相应文件即可. 说明: Google代码风格文件的缩进是 ...

  9. 【面试 springMVC】【第四篇】springMVC的一些问题

    1.springMVC的工作流程是什么样的 1.用户请求到达 2.DispatcherServlet接收请求,发送给处理器映射器 3.处理器映射器handlerMapping,处理找到对应处理器,返回 ...

  10. Python机器学习--聚类

    K-means聚类算法 测试: # -*- coding: utf-8 -*- """ Created on Thu Aug 31 10:59:20 2017 @auth ...