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.Butto
相关文档:
第一种
是通过调用window media player进行播放诸如:wmv,asf等格式文件:
<object align=center class=OBJECT classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 height=320 id=MediaPlayer width=356>
<param name="ShowStatusBar" value="-1">
<param name="Filename" value="电影地址">
& ......
命名空间:
Socut.Data
//##################### CData 类 #####################
实现功能:读取(DataSet方式),插入,更新,删除,统计
调用方法:
public CData myData=new CData();
实际操作:
1,读取
public DataSet ds=new DataSet(); //此DataSet类已经由微软封装提供
ds=myData.GetDataSet("SELECT * from ......
看过微软的网站有时候,是.MSPX的扩展名?其实你也可以配置,很简单。Here We Go!
配置WEB.CONFIG:
<system.web>
<compilation>
<buildProviders>
<add ......
Form 表单:一个页面只能有一个
runat=“server”不是必须的,加上后,会在输出的源代码里多了一行
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGR/8ZxOm5Tn0sfHNJaqE12hKqqJTQ==" />
嘿,这不就是传说中的viewstate吗。原来这就是.net中的FORM跟HTML中F ......
客户端验证方式:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
&nbs ......