Monday, 30 June 2014

Postback events disabled on SharePoint custom webpart after “Export to Excel” button clicked

I created a custom web part for SharePoint 2010 with grid view(.Net) control getting date from data table.I implemented a button "Export to Excel" to export data table value in excel to be saved locally from the grid view.

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 no any event gets working neither "Export to Excel" button itself.

After too many surfing, I found a link having great JavaScript solution as shown below:

<script type="text/javascript" language="javascript">
    //sharepoint postback to work after clicking on export to excel button
    if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' &&
                                           _spBodyOnLoadFunctionNames != null) {
    function supressSubmitWraper() {
        _spSuppressFormOnSubmitWrapper = true;
Just posting this solution to my blog for further use. 

No comments :

Post a Comment