在 page_load 里加上如下代码:
string beforeSubmitJS = "\nvar exportRequested = false; \n";
beforeSubmitJS += "var beforeFormSubmitFunction = theForm.onsubmit;\n";
beforeSubmitJS += "theForm.onsubmit = function(){ \n";
beforeSubmitJS += "var returnVal = beforeFormSubmitFunction(); \n";
beforeSubmitJS += "if(exportRequested && returnVal) {_spFormOnSubmitCalled=false; exportRequested=false;} \n";
beforeSubmitJS += "return returnVal; \n";
beforeSubmitJS += "}; \n";
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alterFormSubmitEvent", beforeSubmitJS, true);
注册javascript程序,然后再按钮提交时发送一个参数:
this._btnSubmit.Attributes["onclick"] = "javascript:exportRequested=true;&#