More Microsoft AJAX views
Fun with Microsoft AJAX UpdatePanel
sys.webforms.pagerequestmanagerparsererrorexception: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.write(), response filters, httpmodules, or server trace is enabled.
Details : Error parsing near ‘<!DOCTYPE html PUBLI’.
So what’s happening here? The UpdatePanel mechanism works by requesting the whole aspx page from the server and then using black-boxed JavaScript code to grab the changes that the UpdatePanel area represents in order to update the browser accordingly. This requires that the UpdatePanel’s client side script gets exactly the page it was expecting. Any changes, such as using document.write or traces will upset this requirement and you get this error. Another way of upsetting this apple cart is if the server decides to totally change the page, i.e. the server issues a Server.Transfer. Server transfer is a very seductive technique because it doesn’t require bouncing any requests off the client, the server simply changes (transfers) from rendering page A to rendering page B. However, when we look back at the UpdatePanels requirements for having the same page then it quickly becomes obvious that it’s going to get upset again! So that’s it, I now know how to avoid upsetting the UpdatePanel, well so you’d think. In the particular case I was asked to look at the server was issuing a page redirect. At first thought you’d think, "aha, it must be the page the UpdatePanel expects", but no. The UpdatePanel is savvy enough to realise that a 303 redirect isn’t really meant for it, so it passes it to it’s container, i.e. normally the browser window. So although you can’t use the "page moved" technique to change the service end-point at least the server code can issue redirects without having to know if the client is a browser or an UpdatePanel. So why am I seeing the error still? Hmm, I’m still not sure. Something somewhere is consuming the 303 redirect and then correctly requesting the page B from the Server. Page B is then consumed by the UpdatePanel, therefore behaving like a Server.Transfer and hence I see the error. Unfortunately the page structure is complex, with a number of dynamically created controls and iframes so something in that goo is consuming the 303 before the UpdatePanel. So what’s a developer to do? Well handle the error that’s what 😉 Rather than write lots of nasty code to dynamically rewrite the UpdatePanel’s JavaScript you can use the following, Sys.WebForms.PageRequestManager endRequest Event
In my case I chose to examine the error condition, if there’s one the change the window.location and redirect the client to an error page. You can examine the args to see exactly what was returned to make more interesting decisions about how to process the error. Also you should mark the error has handled (=true) if you don’t want the UpdatePanel to carry on raising browser errors.
Problems upgrading Silverlight Beta 2 project
Implementation of missing combo control/drop down control
A couple of things that don’t (currently) work in Silverlight
Using XAML triggers:
One mechanism that should work in the final version is the ability to create XAML that responds to an even and can trigger something else, such as a storyboard. This is especially useful for Designers who want to test their designs/animations without having to write procedural code. The XAML is "supported" but simply doesn’t work, you get odd messages about values been out of range. This is the idea anyway…
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
<BeginStoryboard Storyboard="{StaticResouce mystory}"/>
</EventTrigger>
</Rectangle.Triggers>
However, it’s not all bad news, you can use the above technique if you embed the stroyboard rather than using the static resource. However, this isn’t good for a Designer using Blend as currently blend "loses" the storyboard…you can’t win 😉
Embedding code into XAML:
XAML has a special inline code element, <x:Code> that you place procedural code into it. Ok so you need to write the event handler but that’s pretty close to boiler plate code so easy to copy. Plus you don’t have to leave Blend to write it. However, when I tried it Silverlight just didn’t like it and wouldn’t run the page let alone the code.
One transaction performance barrier broken
Silverlight full screen, now with limited keyboard support
getElementById gotcha
<a onMouseOver="elementid.className=’New’" />…<img id="ElementId" src=…>…<div id="elementid">…
so I was asked to find out why this wasn’t working in a number of browsers. Well the first thing I spotted was the non-standard way of accessing the className in OnMouseOver. So I changed it to document.getElementId(‘elementid’).className=’New’; No errors but the style change (which was working in IE with the above code) stopped working in IE. It took a fair bit of head scratching but as you can probably tell by the HTML i’ve added but yet to talk about the problem was the img tag. In the first example of directly setting the className the call is case-sensitive and correctly alters the style of the DIV. However, and this was a surprise to me, getElementById is case-insensitive and was returning the img tag rather than the DIV! Therefore, and it comes as no real surprise, don’t rely on the case when creating unique Ids.
New graphics card
My ageing 6800GT was starting to struggle so I decided it was about time to upgrade. The current choices of cards are bewildering but I finally decided upon a 8800GT cause the price mark is pretty cheap and they provide a decent frame-rate given the fairly old system it’s going into. However, there are two problems (for me) with the 8800GT; 1. Noisy 2. Pumps heat into the inside of the box. So after a bit of a search I discovered the Gainward GeForce Bliss 8800GT 512MB Golden Sample. It’s got a bit of factory overclocking (nice), it’s a dual slot (so pumps heat outside of the box) which is fine for me since I only have one 16x slot, and it’s got it’s own cooler which makes it very quiet. Installing it was pretty easy although the dual face plate was a little deeper than normal which caused it to hit my cases face-plate holder. Luckily as I was scratch my head wondering how to solve the problem it slipped into place. So how does it run?
Under Vista 32-bit it didn’t realise what the card was until I downloaded the latest nVidia drivers, restarted and all was fine. In fact the same thing happened on my XP boot as well. So the installation was pretty easy. Performance? Well I’m not one that’s bothered about playing things with every setting switched so UT2008 and COD4 looked better, UT had more fun bits enabled and was far less Lego like. The big difference was with Clive Barker’s Jericho which was an absolute one legged dog on the 6800 but fine on 8800, in fact there is so much graphic effects going on that I found it difficult to actually see what was going on!
So for £110 I can only recommend it for someone wanting to upgrade their medium gaming rig. Plus it comes with Lara Croft Anniversary…although she normally makes my blood boil…to quote Spaced, "can’t shoot straight you big t*tted b*tch".
Kick it! | DZone it! | del.icio.us