代码改变世界

自定义控件之防用户重复刷新

2008-08-15 16:57  刘少侠  阅读(1165)  评论(1编辑  收藏  举报

 

    近来有用户反映系统老是重复添加记录,一查,原因是用户在提交数据的时候,浏览器反应较慢,用户误以为程序停止,于是再次点击提交按钮,于是问题出现.

    于是想到一种办法,在用户提交数据之后,当前网页最顶端显示一个透明的大小和当前浏览器客户区域同等的DIV,提示用户当前操作正在进行. 如此,用户会看到数据执行过程,就不会再次提交.

时间仓促,代码公布如下,有几处属性需要添加设计师支持. 来日有时间再完善.

 

Code

 

效果:

 

 

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Loading.aspx.cs" Inherits="WebApplication1.Loading" %>
 2 <%@ Register Assembly="Loading" Namespace="Loading" TagPrefix="cc1" %>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4 <html xmlns="http://www.w3.org/1999/xhtml">
 5 <head runat="server">
 6     <title>无标题页</title>
 7 </head>
 8 <body>
 9     <form id="form1" runat="server">
10     <div style="height: 1316px">
11         <cc1:DongLoading ID="DongLoading1" runat="server" BackColor="Aliceblue" ImagePath="hi.gif"
12             TargetControlID="Button1" DongBorderColor="AliceBlue"  />
13         <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
14         <div style="position:absolute; width:300px; height:1300px; border: solid 2px blue;"></div>
15     </div>
16     </form>
17 </body>
18 </html>