代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
防止重复提交
作者:
Dezai.CN
/ 发布于
2011/3/15
/
839
编译成类库 使用
<div><span style="color: #0000ff">using</span><span style="color: #000000"> System; </span><span style="color: #0000ff">using</span><span style="color: #000000"> System.Collections.Generic; </span><span style="color: #0000ff">using</span><span style="color: #000000"> System.ComponentModel; </span><span style="color: #0000ff">using</span><span style="color: #000000"> System.Text; </span><span style="color: #0000ff">using</span><span style="color: #000000"> System.Web; </span><span style="color: #0000ff">using</span><span style="color: #000000"> System.Web.UI; </span><span style="color: #0000ff">using</span><span style="color: #000000"> System.Web.UI.WebControls; </span><span style="color: #0000ff">namespace</span><span style="color: #000000"> BlogLan.Web.Controls { </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"> </span><span style="color: #808080">///</span><span style="color: #008000"> 表示一个防止重复提交的按钮。当用户单击按钮以后,该按钮变灰,不能再次单击,直到重新加载页面或者跳转。 </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"> </span><span style="color: #000000"> [DefaultProperty(</span><span style="color: #800000">"</span><span style="color: #800000">Text</span><span style="color: #800000">"</span><span style="color: #000000">)] [ToolboxData(</span><span style="color: #800000">"</span><span style="color: #800000"><{0}:ClickOnceButton runat=server></{0}:ClickOnceButton></span><span style="color: #800000">"</span><span style="color: #000000">)] </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> ClickOnceButton : System.Web.UI.WebControls.Button { </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"> </span><span style="color: #808080">///</span><span style="color: #008000"> 默认的构造函数。 </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"> </span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> ClickOnceButton() { </span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">afterSubmitText</span><span style="color: #800000">"</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #800000">"</span><span style="color: #800000">正在提交,请稍候...</span><span style="color: #800000">"</span><span style="color: #000000">; </span><span style="color: #0000ff">base</span><span style="color: #000000">.Text </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #800000">"</span><span style="color: #800000">ClickOnceButton</span><span style="color: #800000">"</span><span style="color: #000000">; </span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">showMessageBox</span><span style="color: #800000">"</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">false</span><span style="color: #000000">; </span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">warningText</span><span style="color: #800000">"</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #800000">"</span><span style="color: #800000">确定要提交吗?</span><span style="color: #800000">"</span><span style="color: #000000">; } </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"> </span><span style="color: #808080">///</span><span style="color: #008000"> 获取或设置单击按钮后,按钮上所显示的文本。 </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"> </span><span style="color: #000000"> [Bindable(</span><span style="color: #0000ff">true</span><span style="color: #000000">), Category(</span><span style="color: #800000">"</span><span style="color: #800000">Appearance</span><span style="color: #800000">"</span><span style="color: #000000">), DefaultValue(</span><span style="color: #800000">"</span><span style="color: #800000">正在提交,请稍候...</span><span style="color: #800000">"</span><span style="color: #000000">), Description(</span><span style="color: #800000">"</span><span style="color: #800000">指示单击提交后,按钮上所显示的文本。</span><span style="color: #800000">"</span><span style="color: #000000">)] </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">string</span><span style="color: #000000"> AfterSubmitText { </span><span style="color: #0000ff">get</span><span style="color: #000000"> { </span><span style="color: #0000ff">string</span><span style="color: #000000"> afterSubmitText </span><span style="color: #000000">=</span><span style="color: #000000"> (</span><span style="color: #0000ff">string</span><span style="color: #000000">)</span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">afterSubmitText</span><span style="color: #800000">"</span><span style="color: #000000">]; </span><span style="color: #0000ff">if</span><span style="color: #000000"> (afterSubmitText </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) { </span><span style="color: #0000ff">return</span><span style="color: #000000"> afterSubmitText; } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">string</span><span style="color: #000000">.Empty; } } </span><span style="color: #0000ff">set</span><span style="color: #000000"> { </span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">afterSubmitText</span><span style="color: #800000">"</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> value; } } [Bindable(</span><span style="color: #0000ff">true</span><span style="color: #000000">), Category(</span><span style="color: #800000">"</span><span style="color: #800000">Appearance</span><span style="color: #800000">"</span><span style="color: #000000">), DefaultValue(</span><span style="color: #0000ff">false</span><span style="color: #000000">), Description(</span><span style="color: #800000">"</span><span style="color: #800000">指示是否要显示一个提示框。</span><span style="color: #800000">"</span><span style="color: #000000">)] </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">bool</span><span style="color: #000000"> ShowMessageBox { </span><span style="color: #0000ff">get</span><span style="color: #000000"> { </span><span style="color: #0000ff">return</span><span style="color: #000000"> (</span><span style="color: #0000ff">bool</span><span style="color: #000000">)</span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">showMessageBox</span><span style="color: #800000">"</span><span style="color: #000000">]; } </span><span style="color: #0000ff">set</span><span style="color: #000000"> { </span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">showMessageBox</span><span style="color: #800000">"</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> value; } } [Bindable(</span><span style="color: #0000ff">true</span><span style="color: #000000">), Category(</span><span style="color: #800000">"</span><span style="color: #800000">Appearance</span><span style="color: #800000">"</span><span style="color: #000000">), DefaultValue(</span><span style="color: #800000">"</span><span style="color: #800000">确定要提交吗?</span><span style="color: #800000">"</span><span style="color: #000000">), Description(</span><span style="color: #800000">"</span><span style="color: #800000">指示提示框内所包含的内容。</span><span style="color: #800000">"</span><span style="color: #000000">)] </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">string</span><span style="color: #000000"> WarningText ; { </span><span style="color: #0000ff">get</span><span style="color: #000000"> { </span><span style="color: #0000ff">return</span><span style="color: #000000"> (</span><span style="color: #0000ff">string</span><span style="color: #000000">)</span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">warningText</span><span style="color: #800000">"</span><span style="color: #000000">]; } </span><span style="color: #0000ff">set</span><span style="color: #000000"> { </span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">warningText</span><span style="color: #800000">"</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> value; } } </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"> </span><span style="color: #808080">///</span><span style="color: #008000"> AddAttributesToRender </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #008000"> </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="writer"></span><span style="color: #008000">HtmlTextWriter</span><span style="color: #808080"></param></span><span style="color: #808080"> </span><span style="color: #000000"> </span><span style="color: #0000ff">protected</span><span style="color: #000000"> </span><span style="color: #0000ff">override</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> AddAttributesToRender(HtmlTextWriter writer) { System.Text.StringBuilder ClientSideEventReference </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> System.Text.StringBuilder(); </span><span style="color: #0000ff">if</span><span style="color: #000000"> (((</span><span style="color: #0000ff">this</span><span style="color: #000000">.Page </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) </span><span style="color: #000000">&&</span><span style="color: #000000"> </span><span style="color: #0000ff">this</span><span style="color: #000000">.CausesValidation) </span><span style="color: #000000">&&</span><span style="color: #000000"> (</span><span style="color: #0000ff">this</span><span style="color: #000000">.Page.Validators.Count </span><span style="color: #000000">></span><span style="color: #000000"> </span><span style="color: #800080">0</span><span style="color: #000000">)) { ClientSideEventReference.Append(</span><span style="color: #800000">"</span><span style="color: #800000">if (typeof(Page_ClientValidate) == 'function'){if (Page_ClientValidate() == false){return false;}}</span><span style="color: #800000">"</span><span style="color: #000000">); } </span><span style="color: #008000">//</span><span style="color: #008000">ShowMessageBox?</span><span style="color: #008000"> </span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #0000ff">this</span><span style="color: #000000">.ShowMessageBox) { ClientSideEventReference.Append(</span><span style="color: #800000">"</span><span style="color: #800000">if (!confirm('</span><span style="color: #800000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #0000ff">this</span><span style="color: #000000">.WarningText </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #800000">"</span><span style="color: #800000">')){return false}</span><span style="color: #800000">"</span><span style="color: #000000">); } ClientSideEventReference.AppendFormat(</span><span style="color: #800000">"</span><span style="color: #800000">this.value = '{0}';</span><span style="color: #800000">"</span><span style="color: #000000">, (</span><span style="color: #0000ff">string</span><span style="color: #000000">)</span><span style="color: #0000ff">this</span><span style="color: #000000">.ViewState[</span><span style="color: #800000">"</span><span style="color: #800000">afterSubmitText</span><span style="color: #800000">"</span><span style="color: #000000">]); ClientSideEventReference.Append(</span><span style="color: #800000">"</span><span style="color: #800000">this.disabled = true;</span><span style="color: #800000">"</span><span style="color: #000000">); ClientSideEventReference.Append(</span><span style="color: #0000ff">this</span><span style="color: #000000">.Page.ClientScript.GetPostBackEventReference(</span><span style="color: #0000ff">this</span><span style="color: #000000">, </span><span style="color: #0000ff">string</span><span style="color: #000000">.Empty)); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, ClientSideEventReference.ToString(), </span><span style="color: #0000ff">true</span><span style="color: #000000">); </span><span style="color: #0000ff">base</span><span style="color: #000000">.AddAttributesToRender(writer); } } } </span></div>
试试其它关键字
防止重复提交
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3