Saturday, July 26, 2014

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

Hello Everyone !!

Here I am Posting a common problem which is we usually faces when we use "Export To Excel" button in Custom Web Part.

Please find the solution in below code...

1- Add below script in your Web part

<script type="text/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>

OR

Another solution is replace below form tag in Master Page

Existing...
<form runat="server" onsubmit="if (typeof(_spFormOnSubmitWrapper) != 'undefined') {return _spFormOnSubmitWrapper();} else {return true;}">

Replace With...
<form runat="server" >

Enjoy coding.

No comments:

Post a Comment

SharePoint Deployment Error : The specified path, file name, or both are too long.

Hi, Sometimes we get surprised with below error while deploying wsp file... Solution : To overcome with this issue, we just ne...