Ya know, ASP.NET AJAX (Atlas) and Windows Mobile just seems to be the challenge that just keeps on giving. J
As I talked about yesterday, we now know how to get Atlas and Windows Mobile to work together. The next challenge is to be sure that Atlas correctly recognizes all of the capabilities of IE Mobile. As I mentioned last week, there are two workarounds for the fact that Atlas doesn't recognize IE Mobile.
The first is to set the ClientTarget to 'ie5' in the ASPX pages <%@ Page %> directive. This correctly enables the Atlas features but it causes the page to treat all clients (including desktop clients like IE 7) as if they are IE 5.
The other workaround (arguably this is more a solution than workaround) is to define a *.browser file that properly describes the IE Mobile capabilities. Based on the information provided at this years MEDC, it appeared that the only additional capabilities that the *.browser file needs to define is support for W3CDomVersion 1.0. My observations indicate that this isn't quite accurate. I'm finding that Atlas behaves much better on IE Mobile when the client target is set to 'ie5' than it does when using such a simple *.browser file.
To get Atlas to fully enable everything that IE Mobile supports, I need to workout everything that needs to be in the *.browser file which may take me a little time. In the meantime I've found a reasonable short-term workaround.
Rather than set the ClientTarget directly in the ASPX page which affects all clients. You can add code to check the UserAgent value and set the ClientTarget only when the client is IE Mobile. The key is to let the incoming request progress far enough so that the Request object is instantiated but to set the ClientTarget value early enough so that all the code that depends on the browser capabilities will believe that the client is IE5.
With all this in mind, the right place to set the ClientTarget is to override the Page class' FrameworkInitialize method which is exactly where the ASP.NET framework sets the value when the ClientTarget is set in the <%@ Page %> directive.
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void FrameworkInitialize()
{
base.FrameworkInitialize();
if (Request.UserAgent.IndexOf("IEMobile") > -1)
ClientTarget = "ie5";
}
}
This isn't my preferred long-term solution but it works for now.
As soon as I figure out everything that needs to be in the *.browser file to get the same results, I'll post that information.
Posted
Sep 25 2007, 09:58 AM
by
jim-wilson