提交一次
来源:互联网 发布:单片机预分频器 编辑:程序博客网 时间:2024/04/27 21:39
#region 是否防止用户多次提交页面
/// <summary>
/// 是否防止用户多次提交页面。默认为true。
/// 如果为true,则用户在提交页面时,会出现提示,防止用户在服务器响应之前再次提交。
/// </summary>
public bool OneClick
{
get
{
string key = this.ClientID + "_OneClick";
if (ViewState[key] == null)
{
ViewState[key] = true;
}
return (bool)ViewState[key];
}
set
{
string key = this.ClientID + "_OneClick";
ViewState[key] = value;
}
}
/// <summary>
/// 表单提交时的提示
/// </summary>
protected string mOnSubmitTip = string.Empty;
protected string OnSubmitTip
{
set
{
mOnSubmitTip = value;
}
get
{
if (mOnSubmitTip == "")
{
if (this.CurCulture == 2052)
{
mOnSubmitTip = "正在处理表单,请稍候....";
}
else
{
mOnSubmitTip = "form process, please waiting....";
}
}
return mOnSubmitTip;
}
}
/// <summary>
/// 重新生成html的头和尾
/// </summary>
private void RebuildHtml()
{
#region 增加在表单提交时,防止用户重复提交的措施
int curCtrl;
int count;
HtmlForm form = null;
// 在form上添加提交事件
for (curCtrl = 0, count = this.Controls.Count; curCtrl < count; curCtrl++)
{
form = this.Controls[curCtrl] as HtmlForm;
// 不为NULL
if (form != null)
{
break;
}
}
// RETURN
if (curCtrl == count)
{
return;
}
form.Attributes["onsubmit"] = "try{submitForm(this);}catch(e){}";
// onclick
if (this.OneClick)
{
// 增加显示提示信息的表格
StringBuilder sb = new StringBuilder();
sb.Append("<table id=/"show_panel_on_submit/" ");
sb.Append("style=/"position:absolute;display:none;/" ");
sb.Append("border=0 height=100% width=100%>");
sb.Append("/n <tr>");
sb.Append("/n <td align=center>");
sb.Append(OnSubmitTip);
sb.Append("/n </td>");
sb.Append("/n </tr>");
sb.Append("</table>");
((LiteralControl)Controls[0]).Text += sb.ToString();
// 增加在表单提交时,隐藏表单并显示提示表格的脚本
// 注意:是否进行脚本事件,由页面验证控件内容是否为空决定
sb = new StringBuilder();
sb.Append("/n<script>");
sb.Append("/nfunction submitForm(form) {");
sb.Append("/n if(document.all.validation_summary_on_form_submit.innerHTML == '') {");
sb.Append("/n form.style.display='none';");
sb.Append("/n document.all.show_panel_on_submit.style.display='';");
sb.Append("/n }");
sb.Append("/n}");
sb.Append("/n</script>");
((LiteralControl)Controls[2]).Text += sb.ToString();
// 增加页面验证控件,
// 表单提交时,可通过检验该控件innerHTML来判断提交是否合法
ValidationSummary vs = new ValidationSummary();
vs.ID = "validation_summary_on_form_submit";
vs.Attributes["style"] = "position:absolute;top:-1000;left:-1000";
form.Controls.Add(vs);
}
#endregion
}
// 修改记录2 2010-09-14 朱洁 添加 RebuildHtml(),是否防止用户多次提交页面 结束
#endregion
- 提交一次
- 修改最后一次提交
- 按钮仅提交一次
- 撤销上一次的提交
- 向GitHub的一次提交
- 一个Form一次操作执行多次提交
- form提交一次执行2次
- aspx 提交按钮只能点一次
- 只能提交一次 限制 function submitonce(theform)
- html 一次提交多个表格
- oracle 循环每5000提交一次
- git 修改前一次提交的方法
- git 修改最后一次提交的用户名
- struts2 提交一次重复访问两次数据库
- SpringMVC中的用户数据+文件一次提交
- 一天之内每个IP只能提交一次
- git修改前一次提交的内容
- git撤销最新的一次提交
- content-type
- oracle查询语句记录
- Jquery中each用法
- DirectShow入门之构建Graph图常用技术
- ERP笔记5-系统服务水平
- 提交一次
- 测试的发展前景
- This element neither has attached source nor attached Javadoc and hence no Javadoc could be found
- 关于flex编程中ActionScript3.0中的Object和Dictionary的异同
- 实训第一阶段
- Linux命令
- 软件开发七大原则
- 人民邮电出版社购书满50元即赠送精品图书一本 好机会不容错过~~
- VS2008下打包WinForm程序