ListViewWebPart and crashing browser

ListViewWebPart and crashing browser

In a recent scenario we encountered some issues where the browser (Internet Explorer 9) would crash when clicking the ‘edit page’ button. Once a user would try and edit the page the browser would just crash within a few seconds preventing the user to edit or modify anything on the page. After debugging it a bit it turned out that all team sites that we provisioned would have this issue. Every time we would edit a page within a few seconds the following pop-up showed up and then end our browsing session.

Crashing Internet Explorer 9

When debugging the first few steps where to identify when the issue would happen. First we identified the the platform where the issue occurred; and as it turned out it would only crash in Internet Explorer 9, so other browsers (FireFox / Chrome) or IE 10 didn’t show the problem. Second it appeared only on a custom team site template with some branding. After resetting all branding the issue still appeared so we dug into all the web parts on the page. As it turned out we added some list view web parts with the following snippet:

SPList docList = web.Lists[SPUtility.GetLocalizedString("$Resources: shareddocuments_Title_15", "core", (uint)web.UICulture.LCID)];
string documentViewId = Guid.NewGuid().ToString();
ListViewWebPart listView = new ListViewWebPart();
listView.ID = "g_" + documentViewId.Replace('-', '_');
listView.Title = docList.Title; 
listView.ListName = docList.ID.ToString("B").ToUpper();
listView.ViewGuid = docList.DefaultView.ID.ToString("B").ToUpper();
wpmgr.AddWebPart(listView, "wpz", 0);

You can see we used the ListViewWebPart instead of the XsltListViewWebPart, the result of porting some 'old' code and that turned out to be the issue. When we replaced the code with the following snippet:

SPList docList = web.Lists[SPUtility.GetLocalizedString("$Resources: shareddocuments_Title_15", "core", (uint)web.UICulture.LCID)];
string documentViewId = Guid.NewGuid().ToString();
XsltListViewWebPart listView = new XsltListViewWebPart();
listView.ID = "g_" + documentViewId.Replace('-', '_');
listView.Title = docList.Title;
listView.ListName = docList.ID.ToString("B").ToUpper();
listView.ViewGuid = docList.DefaultView.ID.ToString("B").ToUpper();
wpmgr.AddWebPart(listView, "wpz", 0);

We found that we would no longer crash the browser. Obviously you should use the XsltListViewWebPart anyhow as it is newer and provides more options, however it was quite unexpected that with the default master page and default branding Internet Explorer 9 would throw such a critical error that crashes and needed to be closed and reopened when editing a page. As this behaviour will make it impossible to edit any content on that page.

Leave a Reply