post back issue after file download from SharePoint

hello Geeks,

i was facing  issue to download the file from SharePoint  after I download this file, I can’t click on other buttons even the same download button does not work.  after little search i found some information regarding this issue, SharePoint registers a JavaScript “on submit” handler. In this handler the global variable _spFormOnSubmitCalled is set to true. SharePoint uses this variable to check if a submit was executed and prevents any further submits. Since your “download postback” does not refresh the page this variable remains true. With the effect that all other buttons stop working. In SharePoint 2013  there is a function for resetting _spFormOnSubmitCalled to false already so no need to write your own.

here is my code


 SPList list = webObj.Lists["Documents"];
 SPFile file = list.RootFolder.Files["your pdf file url"];
 Response.ContentType = "Application/pdf";
 Response.AppendHeader("content-disposition", "attachment; filename=" + file);
 Response.Clear();
 Response.Flush();
 Response.End();

 

after writing this code just add the below line to your client side code.

 

<asp:LinkButton ID="lnk" runat="server" OnClick="lnk_Click" Text="<%$ Resources:Portal,DonwloadText %>" CausesValidation="false" OnClientClick="javascript:_spResetFormOnSubmitCalledFlag()"></asp:LinkButton>    

 

Hope this help

Regards

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s