Thursday, October 13, 2011 7:23 PMBackground:
For a week I've been trying to determine why a user control containing an ajax UpdatePanel would post back the first time and then stop working on successive post backs. I finally discovered that it's because the SharePoint masterpage's form has an OnSubmit script that calls the INIT.JS function _spFormOnSubmitWrapper(). Because it's a partial postback the body's OnLoad function (_spBodyOnLoadWrapper()) doesn't fire to set _spFormOnSubmitCalled back to true. Ah ha!..oh but someone thought of that already. In _spBodyOnLoadWrapper(), there is a chunk that checks if there is an ajax script manager and tells it to set spFormOnSubmitCalled back to false before the form is submitted by the update panel.
The problem is when the page first loads in Chrome, OnLoad is intermittently not firing so the event to reset spFormOnSubmitCalled back to false for ajax submissions is never registered. I can modify INIT.JS to make sure spFormOnSubmitCalled never gets set to true for ajax calls in the first place, to make sure all of my form submissions work, but that doesn't change the fact that OnLoad isn't firing and _spBodyOnLoadWrapper() wont execute. I don't really know SharePoint so I don't know what the effects of that would be but it doesn't seem good. There are no script errors on the page.
I've only seen this in Chrome so far and Chrome doesn't do it all the time. The most consistent way for me to reproduce it has been to open a new session, clear my browser cache (only the cach, not cookies, etc) and visit the pages. I think that has caused OnLoad to be skipped 100% of the time. From then on, it's pretty random. It hardly ever skips it if the Chrome developer tools are open and recently started executing OnLoad almost every time for all pages after refreshing any page that uses the masterpage. It's so intermittent that it almost seems like a timing issue, but I don't know what could possibly be executing in parallel to make that a possibility.
P.S. SharePoint 2007
- Edited by _xr280xr_ Thursday, October 13, 2011 8:02 PM
Monday, October 17, 2011 8:10 AM
Thank you for your post.
This is a quick note to let you know that we are performing research on this issue.
Monday, October 17, 2011 12:48 PMThank you Pengyu, I appreciate it.
Tuesday, October 18, 2011 1:47 PMModerator
Thank you for your forum post. Assuming you are referring to Google Chrome [and not the Page / WebPart's webpart title section http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.spchrome(v=office.12).aspx]
Please note SharePoint 2007 has not been tested with Chrome according to http://technet.microsoft.com/en-us/library/cc263526(office.12).aspx. Please let us know if you are able to simulate the same issue in one of the supported browsers (Level 1 or Level 2 supported) i.e. Internet Explorer, FireFox, Netscape Navigator or Safari. If yes, then please let us know the way to reproduce this issue on our end.
However, other members of the community may still have more complete and detailed solution to offer!
Please remember to click 'Mark as Answer' on the post that helps you or click 'Unmark as Answer' if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Microsoft Online Community Support
- Edited by Nishant - MSFTMicrosoft Employee, Moderator Wednesday, October 19, 2011 8:43 AM
Wednesday, March 14, 2012 8:06 AM
add this method and try
protected override void OnInit(EventArgs e)
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
if (scriptManager == null)
scriptManager = new ScriptManager();
Page.ClientScript.RegisterStartupScript(this.GetType(), this.ID, "_spOriginalFormAction = document.forms.action;_spSuppressFormOnSubmitWrapper=true;", true);
if (this.Page.Form != null)
string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
Thanks, Ramachandra Murthy,
- Edited by Ramachandra murthy Wednesday, March 14, 2012 8:07 AM