Friday, December 23, 2011

Appending elements while iterating an XMLNodeList

In a unit test, I had created a populated XMLNodeList and wanted to make sure that the elements were added in a certain spot within the (same parent) XMLDocument after the code under test was finished. I don't remember many of the minute details, but the code would iterate the XMLNodeList and copy the node to the document. The iteration kept failing, however.

After stepping through the code in debug mode, I found that the original XMLNodeList would get emptied out while iterating. If you want to keep the XMLNodeList intact, you need to clone the current node and push the clone into the document.

Wednesday, December 21, 2011

ASP.NET UpdatePanel and PageRequestManagerParserErrorException

I have a page that contains an UpdatePanel that gets updated every 2 seconds to poll for information from the server. With a certain combination of the application running, the UpdatePanel would not refresh in Internet Explorer, but worked fine in Firefox. I finally tracked it down to the UpdatePanel throwing a PageRequestManagerParserErrorException when the data was coming back from the server. There is plenty of information out there about common reasons why this exception is thrown. However, none of those suggestions are valid for my particular need, which is why I can post about it here.

The data coming back from the server included non-displayable characters. Firefox handled this gracefully by displaying a little glyph in the place of the non-displayable characters. Internet Explorer choked on the non-displayable characters. Since I have some control over the data that gets sent to the view, I intercept the non-displayable characters and change them to ‘?’. Now both Internet Explorer are handling the refreshing correctly.