Prevent the user click a button twice
来源:互联网 发布:淘宝网那里卖包包拉链 编辑:程序博客网 时间:2024/05/17 22:04
问题: 用户发邮件说他发现有时候收三遍同样的邮件。
过程:我先开始看code,发现并没有问题,然后发邮件给wendy说没问题,想知道详情。安娜这时候发邮件说可能是duplicate的entries,由于没有submitOnce这样的button control。我恍然大明白了,以为我也偶然发现怎么出了两个同样的entries,但是没有在意。
原因:现在想想,是因为没有disable sumit button,用户点了两次,DB里有了两个三个同样的entries,然后在code出邮件时,是个while语句,每个entry都会发一个邮件。
解决:找到之前老头写的文件,发现非常easy,加进去js文件,在master里面引用,在submit button那里指向,五分钟完事。
附文件:
function submitOnce(myButton){//JavaScript to disable a button after being pressed//Written by Joel Montrose on 9/11/2012////To use this JavaScript, take the following steps: //1.Add this file ("SubmitOnce.js") to the form.//2.Include the following line of code in the Master Page within the <Head> section://<script src="SubmitOnce.js" type="text/javascript"></script>//3.Modify each Button code as follows://Change button from://<asp:Button ID="btnSubmit" runat="server" Text="Submit Request" OnClick="btnSubmit_Click" />//to://<asp:Button ID="btnSubmit" runat="server" Text="Submit Request" OnClick="btnSubmit_Click"//OnClientClick="submitOnce(this);" UseSubmitBehavior="false" CausesValidation="false" />////Client-side validationif (typeof (Page_ClientValidate) == 'function'){if (Page_ClientValidate() == false){return false;}}//make sure the button is not of type "Submit" but "Button"if (myButton.getAttribute('type') == 'button'){//disable the buttonmyButton.disabled = true;myButton.value = "processing...";}return true;}
0 0
- Prevent the user click a button twice
- a method to prevent double click
- Click a button programmatically
- Spring - Spring Data REST - Prevent The Methods in Event Handlers Be Triggered Twice
- Trigger a button click with JavaScript on the Enter key in a text box
- Trigger a button click with JavaScript on the Enter key in a text box
- How to allow a user to click on TextBlocks which return an integer ID in the click handler
- How to programmatically click a WPF button
- Prevent text selection after double click
- To test the operation using the HTTP POST protocol, click the 'Invoke' button.
- Button Click事件追踪
- android Button click event.
- Click button show the confirmation popup first then call the onlick event in C#
- How to click a link / button implemented as a div or span element with WebDriver
- jQuery Click fires twice when clicking on label
- to prevent a memory leak,the jdbc driver has been forcibly unregisterded
- To prevent a memory leak, the JDBC Driver has been forcibly unregistered
- 遇到"To prevent a memory leak, the JDBC Driver has been forcibly unregistered." 后
- 用ORACHK自动化检查数据库系统的健壮性
- sql必知必会读书笔记二
- hdu 4891The Great Pan -----------2014 Multi-University Training Contest 3
- leetcode 虐我篇之(四)Remove Duplicates from Sorted List II
- 为什么呢????没有封号啊
- Prevent the user click a button twice
- 浅析UML之组织结构图
- android项目解刨之时间轴
- 队列的实现
- cocos2d-x-3.2版本win7环境中的搭建
- ReportStudio入门教程(七十五) - 计算项的运算顺序
- 修改登陆密码
- 还算可以的哦0000000000000000
- Android学习——在Android中使用OpenCV的第一个程序