updatepannel中,如何让点击按钮执行一定操作,弹出一个确定提示框? 弹出的选择是否在关闭当前页面的对话框,十分感谢button_click(在button_click(){}默认是关闭当前页面 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20100818/10/56286851-e907-4a41-b896-ef9c9e621637.html 在ajax的updatepannel中这种方法不行,除非方到 updatepannel之外,上午已经试过了 protected void SysInfo() { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "SysInfo", "javascript:return confirm('你确认要删除)", true); } this.ClientScript.RegisterStartupScript(this.GetType(),"ss","<script>alert('不能添加!');</script>");把这句改成ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "success", "<script>alert('不能添加!');</script>", false); ScriptManager.RegisterStartupScript(this.UpdatePanel1,this.GetType(),"aa", "alert('保存成功')", true);这种事可以的,但是如何关闭当前页面? 前台:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ConfirmTest._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title></title> <script> function MyConfirm() { if (confirm("确定要继续吗?") == true) { document.getElementById("hidden1").value = "1"; } else { document.getElementById("hidden1").value = "0"; } form1.submit(); } function CloseCurrPage() { document.getElementById('hidden1').value = '0'; if (confirm("确定要关闭当前页面吗?") == true) { window.close(); } } </script></head><body> <form id="form1" runat="server"> <input type="hidden" id="hidden1" runat="server" /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="测试Confirm" onclick="Button1_Click" /> </form></body></html>后台:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace ConfirmTest{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (this.hidden1.Value == "1") { this.MyGo(); } } protected void Button1_Click(object sender, EventArgs e) { //从数据库中取数据进行判断 //这里简单的改为判断页面上的textbox if (this.TextBox1.Text == "1") { this.ClientScript.RegisterStartupScript(this.GetType(),"ss","<script>alert('不能添加!');</script>"); return; } else if (this.TextBox1.Text == "2") { this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>MyConfirm();</script>"); } else if (this.TextBox1.Text == "3") { MyGo1(); } else { MyGo(); } } //需要继续执行的方法 private void MyGo() { this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('"+this.hidden1.Value+"');document.getElementById('hidden1').value='0';</script>"); } //需要继续执行的方法 private void MyGo1() { this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>CloseCurrPage();</script>"); } }} 关于网站中编码的问题 关于数据采集和正则匹配问题 sql语句没有错误,但在程序执行时却报异常? 谢谢各位大哥了 请大家帮帮想想办法?! 请问如何在一个Form中并排放置两个GridView? webform , vb.net ,怎么改变datagrid翻页符号“< >”的颜色? 版主呀!你怎知我的良苦用心啦!!! 如何把服务器按钮替换成html 按钮 好新鲜的问题~~验证控件的正则表达式.... 求助:客户端操作服务器注册表并运行服务器端应用程序的问题。。。 aspx页面后台向前台传值? 怎样限制每台电脑的注册次数,获取客户端电脑的硬件id?
{
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "SysInfo", "javascript:return confirm('你确认要删除)", true);
}
把这句改成
ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "success", "<script>alert('不能添加!');</script>", false);
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ConfirmTest._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script>
function MyConfirm() {
if (confirm("确定要继续吗?") == true) {
document.getElementById("hidden1").value = "1";
}
else {
document.getElementById("hidden1").value = "0";
}
form1.submit();
}
function CloseCurrPage() {
document.getElementById('hidden1').value = '0';
if (confirm("确定要关闭当前页面吗?") == true) {
window.close();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="hidden" id="hidden1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="测试Confirm"
onclick="Button1_Click" />
</form>
</body>
</html>后台:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace ConfirmTest
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (this.hidden1.Value == "1")
{
this.MyGo();
}
} protected void Button1_Click(object sender, EventArgs e)
{
//从数据库中取数据进行判断
//这里简单的改为判断页面上的textbox
if (this.TextBox1.Text == "1")
{
this.ClientScript.RegisterStartupScript(this.GetType(),"ss","<script>alert('不能添加!');</script>");
return;
}
else if (this.TextBox1.Text == "2")
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>MyConfirm();</script>");
}
else if (this.TextBox1.Text == "3")
{
MyGo1();
}
else
{
MyGo();
}
} //需要继续执行的方法
private void MyGo()
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('"+this.hidden1.Value+"');document.getElementById('hidden1').value='0';</script>");
}
//需要继续执行的方法
private void MyGo1()
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>CloseCurrPage();</script>");
}
}
}