The phonebook doesn’t work… ok?! Hmm it works the first time but not the second time… ok?! Luckily my developer told me that it may have to do with SharePoint 2007 java script and the Ajax functionality he used in the phonebook application.
So I removed things from the master page and at the end I found the java script call making problems.
Ajax and onsubmit="return _spFormOnSubmitWrapper();"
After putting it in the Google search box I found a solution provided by bewise.fr. The following Html can be found in the master page where the second line calls a java script function which sets a variable to true when the form is submitted for the first time. Reloading the page resets the variable to false.
But using Ajax the page is not reloaded and the variable is always true after doing the first Ajax call which causes the second Ajax call to fail.
<body onload="javascript:_spBodyOnLoadWrapper();">
<form id="Form1" runat="server" onsubmit="return _spFormOnSubmitWrapper();">
Solution
So what to do now? Removing the java script call from the master page or implementing the corrected java script provided by bewise.fr under chapter 3.7? Well I decided to not remove the java script call from my custom master page since it may have side effects. I implemented the corrected java script in the master page since I don’t want to modify the out of the box Java script as it may be updated by a future SharePoint update.
The provided java script didn’t work for me since line 7 returned false so I changed it to true (see underlined true):
function _spFormOnSubmitWrapper()
{
if (_spSuppressFormOnSubmitWrapper) {
return true;
}
if (_spFormOnSubmitCalled) {
return true;
}
if (typeof(_spFormOnSubmit)=="function") {
var retval=_spFormOnSubmit();
var testval=false;
if (typeof(retval)==typeof(testval) && retval==testval) {
return false;
}
}
if((typeof(Sys) != 'undefined' ) &&
(typeof(Sys.WebForms) != 'undefined' ) &&
(Sys.WebForms.PageRequestManager.getInstance() != null) &&
(Sys.WebForms.PageRequestManager.getInstance()._postBackSettings.panelID != ''))
_spFormOnSubmitCalled=false;
else
_spFormOnSubmitCalled=true;
RestoreToOriginalFormAction();
_spFormOnSubmitCalled=true;
return true;
}
If the SharePoint java script method is updated I need to check if the custom script is still needed but right now I don’t have a better solution.