| Perfil de PaulioIT BytesBlogListasScraps | Ajuda |
|
30 de junho Fun with Microsoft AJAX UpdatePanel Recently I've been asked to look into a problem where code running in an UpdatePanel was generating the following error; 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. 24 de junho Problems upgrading Silverlight Beta 2 projectFinally had to upgrade one of our development machines to Silverlight 2 Beta 2, and boy did Blend not like it. After installing Beta 2 the project opened in Blend but crashed when you tried to build the project. So uninstalled Blend, installed the latest version and tried again. This time the browser launched but there was an error (from javascript) and an empty page. After some messing around I finally threw my hands in the air and just created a brand new project and copied the assets over. That didn't work either. The new project had a different name and after trying seemingly everything (I'm not a Blend person) I gave up and created yet another project but this time was careful to give it exactly the same name. Finally the project runs. I thought we could have at least had an upgrade old project, oh well that's the life of a beta user I guess.
23 de junho Implementation of missing combo control/drop down control I found Michael Sync blog whilst looking for a Silverlight combo box control, I've not tried it yet but it looks promising since it contains the source too (never take a control without the source code!). 19 de junho A couple of things that don't (currently) work in SilverlightI've just tried a couple of 'tricks' in Silverlight to avoid writing "code-behind" but both failed. 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. 11 de junho One transaction performance barrier brokenOne of my biggest bugbears with .net transactions is that for all but the simplest of cases your transaction will be promoted from a light-weight transaction to a full-blown DTC transaction even when the only database you talk to was SQL Server 2005. However Florin Lazar (a must read for those interested in transactions) has blogged about some welcome improvements to SQL 2008 that mean we can finally go all light-weight...for once that phrase is a good thing (well apart from fast cars, planes, moving house...)!
Silverlight full screen, now with limited keyboard supportSince I blogged about the difficulties of not having keyboard support in Silverlight when you've gone full-screen I thought I'd better say that with the latest release of Silverlight 2 we can now access the basic keyboard navigation, e.g. tab, arrow keys, space, etc. It's better than nothing I suppose. I think I'd prefer some form of keyboard overlay that lights up as you type, so for those paranoid about password sniffing attacks the user could see that the application is catching the keyboard messages regardless of the visual state of underlying application. Somehow I doubt that will happen.
08 de junho getElementById gotcha I was looking, and I can't stress this enough, at someone else's HTML/JavaScript. The code looked something like; <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. 01 de junho New graphics cardMy 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? Kick it! | DZone it! | del.icio.us
|
|
|