【转载】asp.net 后台弹出提示框
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);
}
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 后台弹出提示框的更多相关文章
- asp.net 后台弹出提示框
1.后台弹出提示信息方法 Response.Write("<scripttype="text/javascript">alert('你所查询的数据不存在!') ...
- [转] 在Asp.net前台和后台弹出提示框
一.在前台弹出提示框 1.点击"A"标记或者"控件按钮"弹出提示框 <asp:LinkButton ID="lbtnDel" runa ...
- 【转】在Asp.net前台和后台弹出提示框
源地址:http://blog.sina.com.cn/s/blog_5200dd680100mkk0.html
- C# ASP response.write()弹出提示框后页面布局被打乱
发现在使用了response.write后样式发生了变化,位置和字体都不正确.Response.Write("<script>alert(')</script>&qu ...
- SilverLight 页面后台方法XX.xaml.cs 创建JS,调用JS ,弹出提示框
1.Invoke和InvokeSelf [c-sharp] view plaincopy public partial class CreateJSDemo : UserControl { publi ...
- 每日学习心得:CustomValidator验证控件验证用户输入的字符长度、Linq 多字段分组统计、ASP.NET后台弹出confirm对话框,然后点击确定,执行一段代码
2013-9-15 1. CustomValidator验证控件验证用户输入的字符长度 在实际的开发中通常会遇到验证用户输入的字符长度的问题,通常的情况下,可以写一个js的脚本或者函数,在ASP ...
- iOS bug 之 H5 页面没有弹出提示框
描述:在安卓上有提示框,但是在iOS上没有提示框. step 1: 失误,是我没有在正确的位置设置网址. step 2: 修改之后,测试页能弹出提示框,但是正式的页面没有提示框. step 3: 我输 ...
- C#自动关闭弹出提示框
自动关闭弹出提示框(用一个小窗体显示提示信息):例如在一个form窗体中弹出自动关闭的提示框1.首先创建一个弹出提示信息的窗体 AutoCloseMassageBox,在里面拖一个lable控件,去掉 ...
- android标题栏上面弹出提示框(二) PopupWindow实现,带动画效果
需求:上次用TextView写了一个从标题栏下面弹出的提示框.android标题栏下面弹出提示框(一) TextView实现,带动画效果, 总在找事情做的产品经理又提出了奇葩的需求.之前在通知栏显示 ...
随机推荐
- python3里的Urllib库
首先Urllib是python内置的HTTP请求库. 包括以下模块: urllib.request 请求模块: urllib.error 异常处理模块: urllib.parse url解析模块: u ...
- yii 之增加数据
模型代码: <?php namespace app\models; use yii\db\ActiveRecord; class Test extends ActiveRecord{ publi ...
- WebView跳转到底部
webview中有个computeVerticalScrollRange方法,是protected的,可以用反射,也可以自己写一个view继承webview,实现computeVerticalScro ...
- Elasticsearch使用syslog发送Watcher告警事件
https://blog.csdn.net/mvpboss1004/article/details/70158864?locationNum=9&fps=1
- luogu P3512 [POI2010]PIL-Pilots
题目描述 In the Byteotian Training Centre, the pilots prepare for missions requiring extraordinary preci ...
- bzoj2555(lct维护sam)
题意: (1):在当前字符串的后面插入一个字符串 (2):询问字符串s在当前字符串中出现了几次?(作为连续子串) 字符串长度<=6e5,询问总长度<=3e6 分析: 考虑建个sam,然后把 ...
- Java中的网络基础
先来一张图记录一下大概思路,之后再更新具体的代码实现.基本上来说,前半部分自己会编写一个基于socket编程的多客户端dos聊天服务器,后半部分可以实现与已有的一些服务器(比如www.google.c ...
- 5.Longest Palindrome substring
/* * 5.Longest Palindrome substring * 2016-4-9 by Mingyang 自然而然的想到用dp来做 * 刚开始自己做的时候分的条件太细,两个index相等, ...
- Chrome常用URL命令(伪URL)
在Chrome地址栏输入chrome://chrome-urls/可以看到所有的Chrome支持的伪RUL 1.chrome://accessibility/ 可达性分析,默认是关闭的,点击acces ...
- Spring Boot集成Spring Data Reids和Spring Session实现Session共享(多个不同的应用共用一个Redis实例)
从Redis的Key入手,比如Spring Session在注解@EnableRedisHttpSession上提供了redisNamespace属性,只需要在这里设置不同的值即可,效果应该是这样的: ...