asp.net 捕获用户操作 确认删除
来源:互联网 发布:脸型测试软件 编辑:程序博客网 时间:2024/06/05 04:17
前台:
<!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();
}
</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
{
MyGo();
}
}
//需要继续执行的方法
private void MyGo()
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('是不是想要这个效果呢?');</script>");
hidden1.Value = "";//一定要恢复初始化
}
private void MyGo1()
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('取消操作?');</script>");
hidden1.Value = "";//一定要回复初始化
}
}
}
<!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();
}
</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
{
MyGo();
}
}
//需要继续执行的方法
private void MyGo()
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('是不是想要这个效果呢?');</script>");
hidden1.Value = "";//一定要恢复初始化
}
private void MyGo1()
{
this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('取消操作?');</script>");
hidden1.Value = "";//一定要回复初始化
}
}
}
0 0
- asp.net 捕获用户操作 确认删除
- ASP.net确认删除提示
- asp.net 删除前确认
- asp,net 删除前确认
- asp.net 删除确认对话框
- asp.net确认删除实现?
- asp.net 删除确认对话框
- ASP.NET中Gridview读取数据表列表页面常用操作-序号,编辑,删除,删除确认
- asp.net gridview添加删除确认对话框
- 在ASP.NET 2.0中操作数据::为删除数据添加客户端确认
- asp.net 用户控件实现后台确认提醒框
- ASP.NET中为GridView添加删除确认提示框
- 有确认删除的gridview(vs2005 asp.net)
- asp.net GridView 删除时弹出确认…
- 删除确认操作 c#
- 用户登陆操作(ASP.NET)
- asp.net中弹出确认窗口(confirm),实现删除确认的功能
- asp.net中弹出确认窗口(confirm),实现删除确认的功能
- poj 1700 贪心过河
- scanf()、gets()和getline()读取输入
- asp.net 删除确认对话框
- 解决YUM下Loaded plugins: fastestmirror Determining fastest mirrors
- springmvc中forward和redirect
- asp.net 捕获用户操作 确认删除
- c代码处理
- 多条件筛选界面DropDownMenu使用总结
- 争取做一个早睡早起,有思想也有的趣程序员
- 单链表的冒泡排序以及逆序(交换指针法)
- consul部署 docker篇
- HDU_1009 FatMouse' Trade 【贪心】
- ubuntu16.04中将python3设置为默认
- CSS:z-index