易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET中防止页面多次提交的代码实现


此处提供的代码用来实现当asp.net页面中的某个Button被点击后disable掉该页面中所有的Button,从而防止提交延时导致的多次提交。基于之前的onceclickbutton脚本.
//ASP.NET中防止页面多次提交的代码:javascript< script language="javascript"> < !-- function disableOtherSubmit() {
var obj = event.srcElement;
var objs = document.getElementsByTagName('INPUT');
for(var i=0; i< objs.length; i++)
{
if(objs[i].type.toLowerCase() == 'submit')
{
objs[i].disabled = true;
}
}
} //--> < /script>//ASP.NET中防止页面多次提交的代码:asp.netpublic class PreventMultiClick : System.Web.UI.Page {
protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.LinkButton LinkButton1; protected System.Web.UI.WebControls.Button Button3; private void Page_Load(object sender, System.EventArgs e)
{
this.GetPostBackEventReference(this.Button3);
//保证 __doPostBack(eventTarget, eventArgument) 正确注册 if(!IsPostBack)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function')
{
if (Page_ClientValidate() == false)
{
return false;
}
}"); //保证验证函数的执行 sb.Append("if(window.confirm('are you sure?')==false) return false; ");
//自定义客户端脚本 sb.Append("disableOtherSubmit(); ");
// disable所有submit按钮 sb.Append(this.GetPostBackEventReference(this.Button3));
//用__doPostBack来提交,保证按钮的服务器端click事件执行 sb.Append("; ");
Button3.Attributes.Add("onclick",sb.ToString());
}
} #region Web Form Designer generated code override protected void OnInit(EventArgs e)
{
// // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent();
base.OnInit(e);
}
/// < summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// < /summary> private void InitializeComponent()
{
this.But


相关文档:

ASP.NET代码生成工具codesmith

     这两天熟悉公司的网站前台和后台的数据结构和业务逻辑,看到许多工程下都有一个叫“Base”的文件夹,里面有一系列带“***.Generated.cs”的文件(比如Bulletin.Generated.cs)。懂点编程知识和英语的人都应该会想到这是用什么工具自动生成的吧?以前我也知道C#有根据模板自动 ......

asp.net中的html标签runat=server时的映射

asp.net中的html控件runat=server时的映射 1、标准xhtml标签:http://blog.csdn.net/TangZhongxin/archive/2009/07/31/4398487.aspx 2、绝大多数标签都映射到“System.Web.UI.HtmlControls.HtmlGenericControl”,它们的共同特性是“信息只读,仅供显示的标记”:
div,span,p,h1,h2,h3,h4,h5,h6,ul,li,dl,dt,dd, ......

关闭数据库连接的高效方法 (asp.net 2.0 C#)

 
我们还可以采用一种更加简便的方
法来实现上述程序的功能。这就是将SqlConnection对象包含到using区块中,这样程序会自动调用Dispose()方法释放
SqlConnection对象所占用的系统资源,无需再使用SqlConnection对象的Close()方法。
范例程序代码如下:
public partial class _Default : System.Web.UI.Page
{
......

由浅入深讨论Asp.net资源文件

篇一:基础应用
资源文件通常被用在多语言版本的产品和项目当中,通过简单的设置和引用即可实现不同语言的转变,相当的方便。在.Net中一般可以包括字符串、图像、图标、音频、文本文件等,有相当一部分人和公司在开发的过程中都把这些资源放置在专门的文件夹中(我和我目前的公司也如此),通过相对路径加以引用,也很方便 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号