Home > Microsoft SharePoint, MOSS2007 > After “Export to Excel” button click other click/postback events disabled on SharePoint custom webpart

After “Export to Excel” button click other click/postback events disabled on SharePoint custom webpart

While working I came across a difficult situation and not able to found the correct reason behind the issue.

I created a custom web part for MOSS2007 with ASP.net grid view control getting date from list using CAML query and display the data in tabular format. Export to excel functionality required to provide the data in excel to be saved locally from the grid view was one of the requirement I implemented using gridview.RenderControl() method.

I implemented the requirement completely and tested it and as expected it is working perfectly. But if we once clicked the “Export to Excel” button after words other control stops responding like sorting on grid view header, pagination stops posting back on click event.

Then started digging into the issue found the details in one of the telerik grid related post.

Issue is the resubmission of form is stopped by SharePoint to prevent the again and again requesting without the previous request completes. SharePoint maintains a JavaScript flag for this which we need to clear to allow the postback to work after Export to excel.

Solution I used is added following script on the custom web part.Other solutions also available for this problem which explained in  telerik grid related post.

<script type="text/javascript" language="javascript">

//sharepoint postback to work after clicking on export to excel button

if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' &&
                                           _spBodyOnLoadFunctionNames != null)
{
_spBodyOnLoadFunctionNames.push("supressSubmitWraper");

}

function supressSubmitWraper() {

_spSuppressFormOnSubmitWrapper = true;

}

</script>
Advertisements
  1. JK
    July 18, 2012 at 7:56 pm

    I had the same issue, its working for me now,
    Thank you for the post
    JK

  2. Juande
    July 25, 2014 at 10:19 am

    Thanks a lot!!

  3. January 27, 2016 at 7:44 pm

    thanks Prasad! this worked perfectly.

  4. Faye
    April 7, 2016 at 2:12 pm

    Wow thank you.

  5. October 18, 2016 at 11:51 am

    wow thank you.

  1. July 5, 2014 at 2:54 pm

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

%d bloggers like this: