Joseph Michael Pesch
VP Programming

jQuery $(document).ready() Not Working with ASP.Net UpdatePanel PostBack

by 27. September 2013 20:21

When using jQuery and $(document).ready() event along with an ASP.Net UpdatePanel the $(document).ready() event will only fire on the initial page load and will not fire on subsequent AJAX postbacks via the UpdatePanel.  There are a couple of common solutions posted to deal with this (shown below).  My preference is the first option which seems cleaner and has proven more reliable for me.

Solution 1:  Wrap the $(document).ready() event inside a pageLoad() function since the AJAX postback will always fire the pageLoad() event function.

function pageLoad() {
  $(document).ready(function () {
    DoPageInitialization();
  });
}

Solution 2:  Add a reference to the PageRequestManager and register your function to the add_endrequest() event.

$(document).ready(function() {
  // Still needed as the PageRequestManager below only fires on the postback...
  DoPageInitialization();
});
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function() {
  // Secondary binding for all AJAX postbacks through the UpdatePanel
  DoPageInitialization();
});

function DoPageInitialization() {
  ... Document Ready Code Here ...
}


Here is a good post that goes into more details on both $(document).ready() and pageLoad()
http://encosia.com/document-ready-and-pageload-are-not-the-same/

Tags:

ASP.Net | JavaScript | JQuery

SharePoint WebPart Maintenance Page

by 5. September 2013 12:09

Issue with SharePoint is that the WebParts already in place on an existing page don't indicate what type of web part they actually are.  This is frustrating if it is not obvious what type of web part you are looking at.  In order to get a better view of the WebPart in question you can navigate to the WebPart Maintenance Page by entering a URL like this: http://yoursite/whatever/default.aspx?contents=1

Tags:

Sharepoint