怎么防止重复提交牛
2021-08-24 13:01:00 菏泽汽车网
怎么防止重复提交!
如何防止用户连续点击多下BUTTON后将数据插入到数据库中
加一个hidden。生成表单时,生成一个唯一的之。
一个是对我们的系统会产生不均衡压力 在保存真实数据之前,看该hidden的值是归属的表单是否已经提交过。
禁止按钮也可以刷新,你可以在点击按钮禁卡按钮,设置页面过期,并后跳转到另外一个页面,
可以使用令牌来达到功能。在服务器保存一布尔值在Session中,在提交是验证Session值。
第一次点击后,将able = false;数据存储完后,在类似这样的语句后面 ose(); 加上一句 able=true;
类似这样
Button1_Click(object sender,EventArgs e)
{
able =false;
SaveData();//假设这个方法是保存数据的,执行完保存,把Enable启用即可。
able = true;
}
人家说的是如何防止多次单击Button,没说是 aspx 页面。
if your Button control doesn\'t need to set OnClientClick property, you can just do this:
asp:Button ID=\"SearchButton\" runat=\"server\" Text=\"查詢\" OnClientClick=\"sabled=true;bmit();\" UseSubmitBehavior=\"false\" /
else if your Button Control need to set OnClientClick property:
OnClientClick=\"return confirm(\'您確定要修改嗎?\');\"
you should use JavaScript or jQuery to avoid dummy users\' double clicking, like this:
html xmlns=\"\"
head runat=\"server\"
title未命名頁面 /title
%-- 以下可用
style type=\"text/css\"
.disable
{
border-style:none;
border-width: thin;
background-color:Transparent;
color: #CCCCCC;
cursor:wait;
}
/style
script type=\"text/javascript\" language=\"javascript\"
function DisableButton()
{
tElementById(\"Button1\").className = \"disable\";
tElementById(\"Button1\").value = \'正在提交.\';
tElementById(\"Button1\").onclick=Function(\"return false;\");
return true;
}
/script
/head
body
form id=\"form1\" runat=\"server\"
div
asp:Button ID=\"Button1\" runat=\"server\" Text=\"Button(JS,CSS)\" /
/form
/body
/html
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
d(\"onclick\", \"return DisableButton();\");
}
}
}
if your Button control doesn\'t need to set OnClientClick property, you can just do this:
asp:Button ID=\"SearchButton\" runat=\"server\" Text=\"查詢\" OnClientClick=\"sabled=true;bmit();\" UseSubmitBehavior=\"false\" /
else if your Button Control need to set OnClientClick property:
OnClientClick=\"return confirm(\'您確定要修改嗎?\');\"
you should use JavaScript or jQuery to avoid dummy users\' double clicking, like this:
html xmlns=\"\"
head runat=\"server\"
title未命名頁面 /title
%-- 以下可用
style type=\"text/css\"
.disable
{
border-style:none;
border-width: thin;
background-color:Transparent;
color: #CCCCCC;
cursor:wait;
}
/style
script type=\"text/javascript\" language=\"javascript\"
function DisableButton()
{
tElementById(\"Button1\").className = \"disable\";
tElementById(\"Button1\").value = \'正在提交.\';
tElementById(\"Button1\").onclick=Function(\"return false;\");
return true;
}
/script
/head
body
form id=\"form1\" runat=\"server\"
div
asp:Button ID=\"Button1\" runat=\"server\" Text=\"Button(JS,CSS)\" /
/form
/body
/html
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
d(\"onclick\", \"return DisableButton();\");
}
}
}
短效降压药和长效哪个副作用大积食消化不良怎么办
南宁妇科医院哪家好
- 上一篇:怎么防止重复提交覆盖
- 下一篇:推出面向应用的牛