.net后台弹出提示消息代码

Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('您不需要销假!');</script>");

 

Response.Write("<script type='text/javascript'>alert('修改成功!');</script>");

 

this.LinkButton3.Attributes.Add("onclick", "return confirm('确定要删除吗?');");

 

Page.RegisterStartupScript("aa", "<script>if(confirm('您没有登录,所以不能使用页面中功能,如需登录请点击确定!'))location.href='../Login.aspx' </script>");

 

 
 
 
 
 
其他
--------------------------------------------------------------------------------------------------------------------------------------------------------

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>

posted @ 2015-04-14 14:30  shawli  阅读(286)  评论(0编辑  收藏  举报