解决方法如下:
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;";
这样可以解决这个问题。
原理:页面按钮提交时会调用一个内置的方法并修改一个内置变量_spFormOnSubmitCalled,我们通过按钮来调用方法重置
这个参数的值,达到系统检索页面时,一直默认为未提交状态。
转自:http://topic.csdn.net/u/20090916/15/b54a63a7-77a8-408c-9884-db1fbd5e3f4a.html