.net C# 利用Session防重复点击防重复提交
2021-03-31 11:27
标签:button origin wpa ada public cli ade datetime -- using System; public partial class Default4 : System.Web.UI.Page protected void Button1_Click(object sender, EventArgs e) //利用插入和显示数据量特别大的一张表来模拟网络卡的情况 GridView1.DataSourceID = "ObjectDataSource1"; DateTime time2 = DateTime.Now; Label1.Text = "用时:" + ts.TotalSeconds.ToString() + ",当前时间:" + DateTime.Now.ToString(); .net C# 利用Session防重复点击防重复提交 标签:button origin wpa ada public cli ade datetime -- 原文地址:https://www.cnblogs.com/yubufan/p/9260682.html
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session["fangchongfu"] = DateTime.Now.ToString();
}
}
{
DateTime time1 = DateTime.Now;
DateTime lastTime = Convert.ToDateTime(Session["fangchongfu"].ToString());
TimeSpan ts = time1 - lastTime;
if (10 > ts.TotalSeconds)//小于10秒,则判定为重复提交
{
return;
}
Session["fangchongfu"] = DateTime.Now.ToString();
DataSet1TableAdapters.testbeizhuTableAdapter bzAda = new DataSet1TableAdapters.testbeizhuTableAdapter();
bzAda.InsertQuery();
GridView1.DataBind();
}
}
文章标题:.net C# 利用Session防重复点击防重复提交
文章链接:http://soscw.com/index.php/essay/70441.html