Friday, March 27, 2015

Export to Excel issue - no events work

Post Back does not work after writing files to response or
After Export To Excel Button Event No Events Firing In Sharepoint?


I had this issue with sharepoint. I have a button on the page that sends a file and after clicking the button, the rest of the form was unresponsive. Turns out it is a sharepoint thing that sets the variable _spFormOnSubmitCalled to true to prevent any further submits. When we send a file this doesn't refresh the page so we need to manually set this variable back to false.
On your button in the webpart set the OnClientClick to a function in your javascript for the page.<asp:Button ID="generateExcel" runat="server" Text="Export Excel"OnClick="generateExcel_Click" OnClientClick="javascript:setFormSubmitToFalse()" />
Then in the javascript I have this function.
<script language="javascript" type="text/javascript">
    function setFormSubmitToFalse() {
        setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000);
        return true;
    }
</script>
The 3 second pause I found was necessary because otherwise I was setting the variable before sharepoint set it. This way I let sharepoint set it normally then I set it back to false right after.

Thursday, March 12, 2015

SharePoint Performance Improvement with custom applications

Notes:

The following documented resources from the Internet are applicable to, or have been used to compile and validate the content of, this document:
·         SharePoint Developer Center: http://msdn.microsoft.com/en-us/sharepoint/default
·         Best Practices with SharePoint Foundation: http://msdn.microsoft.com/en-us/library/ee556427(office.14).aspx 



SharePoint Performance improvement:
1. Impersonation can significantly affect performance and scaling. It is generally more expensive to impersonate a client on a call than to make the call directly. 

3. Using PageAsyncTask to improve the performance of your website
     
5.    SharePoint 2010 Performance – Improvement Steps
a.    Use XSLT instead of grids.
b.    Disable view state if you are not performing any use actions.
c.    Don’t throw exceptions; re throw exceptions are much costlier in terms of memory consumption and execution.
d.    Minimize exception handling blocks, use exception block where ever you are not able to handle or pretend exceptions.
e.     
6.    Don’t run production ASP.NET Applications with debug=”true” enabled
a.    If you publish using Debug mode, your generated files have debugging enabled and that will impact the performance.
b.