0

With some success I'm using this suggested code to export a gridview to CSV (or in my case a TSV).

I click my button, the page post's back and the TSV is delivered. Great.

However, after that postback no other controls (dropdownlists with autopostback set to true and buttons - one submit the other a javascript triggered postback button) will postback to the server.

Possible clue: looking at the Google Chrome Network tab the POST for the CSV is considered "Cancelled".

In case they offer any assistance, here are the REQUEST and RESPONSE headers for the CSV - I've blanked a couple related to security:

REQUEST:

POST /Perspective/SitePages/User_Email_List.aspx HTTP/1.1
Host: as-sharepoint
Connection: keep-alive
Content-Length: 8740
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://as-sharepoint
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
Content-Type: application/x-www-form-urlencoded
DNT: 1
Referer: http://as-sharepoint/Perspective/SitePages/User_Email_List.aspx
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: WSS_KeepSessionAuthenticated={xxx}

RESPONSE:

HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/text
Server: Microsoft-IIS/7.5
SPRequestGuid: xxx
Set-Cookie: WSS_KeepSessionAuthenticated={xxx}; path=/
X-SharePointHealthScore: 1
Set-Cookie: WSS_KeepSessionAuthenticated={xxx}; path=/
Content-Disposition: attachment;filename=EmailList.tsv
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 14.0.0.4762
Date: Tue, 19 Mar 2013 13:40:18 GMT

Other bits of possible related information:

  • The method I am calling resides in a tag on the page (This is a Sharepoint website which make codebehinds difficult)
  • I have a feeling this is related to the chunked download not being closed correctly, but I can't be sure.

If any more info is needed, I'm free to offer it!

Community
  • 1
  • 1
chrsmrrtt
  • 197
  • 3
  • 14

1 Answers1

1

I have recently had this issue it is a known problem. something about SharePoint not allowing multiple postbacks. Please look at the following link for how this person resolved it.

http://blogs.msdn.com/b/bspann/archive/2009/06/29/exporting-binary-files-inside-sharepoint-webpart.aspx

As for how I resolved my issue, I used DexExpress controls and I had a ASPxButton to kick off a server side code to export the grid. and I also attached some javascript code to the onClick event on the client to set the following variables _spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;

<dx:ASPxButton runat="server" ID="btnExportGrid" Text="Export Data" AutoPostBack="False" OnClick="btnExportGrid_Click"   >
    <ClientSideEvents Click="function(s, e) {_spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;}" />
</dx:ASPxButton>

I hope this helps.

Ed Mendez
  • 1,510
  • 10
  • 14
  • I'm going mark this answer as useful, but not accept this as the answer. Although I can't confirm whether the proposed code fix works, I transfered my code out of a Sharepoint master-page driven aspx to just a vanilla aspx page and - what would you know - it worked! Therefore this answer pointed me in the right direction. Thanks Ed! – chrsmrrtt Mar 20 '13 at 09:36