ASP.NET AJAX and Windows Mobile - Huge Breakthrough

You Can Take it With You

Syndication

News

  • Don't miss the next Windows Mobile Webcast... Unit Testing for Mobile Devices: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032382824&EventCategory=4&culture=en-US&CountryCode=US.

Much to my pleasent surprise, I now have some basic ASP.NET AJAX (Atlas) pages working on Windows Mobile without modifying any of the Atlas client-side scripts.

Over the weekend, I was thinking more and more about the concept of modifying the Atlas client-side scripts. Although I was willing to do it, I felt it was worthwhile to look at a couple of more things before I took that leap. Thankfully I did.

You’ll recall that I mentioned last week that the Atlas scripts just don’t seem to work with Windows Mobile. I then went on to dig into the details of the scripts and confirmed that there was code in there that just would not work with Windows Mobile. Well it turns out that my observation was correct but needs to be qualified…

The accurate statement is that the Debug version of the Atlas scripts contains code that just won’t work on Windows Mobile.

If you’ve ever looked at the release version of the scripts you know they are very hard to work with. There is a minimum of whitespace and virtually no carriage-returns. Also all of the variables are named a, b, c, d… This is all done, of course, to minimize the size of the script files. The debug scripts, on the other hand, are written normally with carriage-returns, indentation, proper variable names, etc.

All of my testing was done with the debug scripts (Visual Studio default) and all of my research was done with the readable debug scripts.

Well get this, the release version of the scripts have somewhat different functionality from the debug versions; most notably, the release scripts remove a number of error checks. These checks include many of the checks that are used when connecting events to the DOM. In release mode, the steps in this process still fail as they do in the debug scripts but the release scripts ignore the errors. This ultimately allows the pieces of the client-script code that do work with Windows Mobile to run and setup some basic events.

These differences allow the MEDC demo I mentioned last week to work as long as your project is in release mode or you explicitly set the script manager to use the release scripts.

That’s one problem down ... On to the next...

Now when it came to my simple test code, it turns out that just changing to the release scripts does not solve the problem. I owe a huge Thank You to Reed Robinson at Microsoft for resolving this issue. The page I was using for my tests had a button that one clicks to update one Label (but not the other Label). Well because the button by default generates a submit and the Windows Mobile DOM doesn’t have the properties necessary for the Atlas scripts to wire-up everything they need, which include the form object's submit and click events, the page was always doing a full update.

Reed pointed out that if I set the button’s UseSubmitBehavior property to false and provide a server-side click event handler that things work. Once I looked at the generated code this makes perfect sense. When you disable the submit behavior, the client side script handles the button’s client-side onClick event  (instead of form events) to initiate the server call. IE Mobile supports this event just fine so things work.

Note: (added about 90 miutes after original post) I've experimented further and it appears that the server-side click event handler is not necessary. It appears that setting UseSubmitBehavior to false is all that's necessary.

So I’m happy to report that we can use Atlas with Windows Mobile – we’ll just need to compile a complete list of do's and don't's. I really wish it would’ve occurred to me much sooner to switch out of Visual Studio's default setting of debug. In hindsight (usually 20/20 J), it should’ve been part of my experiments. I can’t thank Reed Robinson enough for his help in getting the button event behavior worked out.

With these breakthroughs, I should be able to start putting together some samples real soon.

 


Posted Sep 24 2007, 11:53 AM by jim-wilson

Comments

Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 11-02-2007 7:41 AM
If you're doing AJAX work with IE Mobile, one proble you run into is that ASP.NET doesn't properly recognize the new IE Mobile browser included with Windows Mobile 6. The problem is that the *.browser files included with ASP.NET do not know how to recognize the new user-agent string.

You can get the necessary *.browser file contents from here: http://www.pluralsight.com/blogs/jimw/archive/2007/10/23/48836.aspx

-Jim
Freesc wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 02-04-2008 8:22 AM
it's great.but i feel a little bit sad that VS2008 has no template for Mobile Web Application
Andre Ribeiro wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 02-26-2008 2:51 AM
Hi Jim, thank you for the video you made available with this!! I just have one more question: do you have any ideia why are the ajax timers from my page only doing the Asy. Postback once? I'm using IEMobile 6.12 for testing...
Any help will be very welcome!!


Thanks in advance!
Andre Ribeiro
Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 02-26-2008 6:19 AM
Andre;

I'm a little buried today getting ready for my "LINQ for Devices" Webcast tomorrow. (http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032358820)

If you can ping me again Wednesday afternoon or Thursday, I'll take a look at it then.

Jim
André Ribeiro wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-03-2008 1:27 AM
Hi again Jim!

Could you please give me some feedback now? I now have discovered that the timer starts working if you force a postback of the UpdatePanel with a button control.

Hope the Webcast went fine!

Thank you
André Ribeiro
Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-03-2008 5:51 AM
Andre;

Sorry for the delay - I just have an endless queue of things to do; sometimes balancing and prioritizing everything is difficult at best. :-)

I'll have a look today and see what I can figure out.

Jim
Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-03-2008 7:18 AM
Andre;

Are you using VS2005 or VS2008? I'm using VS2008 to try and recreate and things are breaking differently for more than what you've described [but they are still breaking though :-) ]

Jim
André Ribeiro wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-03-2008 7:43 AM
Hi jim, thanks for giving me some of your precious time! :)

I'm using VS2005 and getting kind of nuts with this... as the page grows, the complexity of all the workarounds I must keep in mind is growing exponentialy... :S

About the timers, i've also found that update doesn't need to be with a button, but with anything... it just have to happend for the timer to start counting beyond the first time...

Once more, thank you very much!! :)
André Ribeiro
Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-04-2008 11:34 AM
Andre;

Just a quick update to let you know I haven't disappeared. :-)

I'm setting up a virtual machine right now that has VS2005 & the AJAX extensions so I can put together a better test. I didn't want to use any of my regular machines because they all have VS2008 installed and I'm concerned that the VS2008 AJAX features and the VS2005 AJAX Extensions might interfere with one another.

I'll follow up with you as soon as I have a handle on the issue.

-Jim
André wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-05-2008 9:16 AM
Jim,

thanks for the effort, i really apreciate it!

Sorry if I'm bothering you with my questions but this is really important.
I have another doubt...
What about the imagebutton control? It doesn't have the useSubmitBehaviour property to set...and when pressed it refreshes the entire page :(


Do you have any idea on how to work this out?

Thanks again! I'll never be tired of thanking you! :)
Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-05-2008 9:30 AM
Andre;

No bother at all - I'm happy to help. I sometimes have to tend to other things for a bit which can cause a delay in my replies but I'm always happy to help.

In terms of the image button, I think we may need to be creative. Can you try attaching your own client-side click event handler and have the handler call the same client-side function that a regular button calls when UseSubmitBehavior is set to false. You'll have to look at the generated client-side code for the regular button and then just adapt it to your imageButton - one of the key things is to be sure to pass the correct control name as the first parameter to the funciton. I'm not sure that this will work but it's where I'd start.

There are definitely a number ASP.NET AJAX controls that are just too difficult to make work with WM, hopefully the image button isn't one of those.

- Jim
André Ribeiro wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-06-2008 3:09 AM
Hello Jim, thanks for the tip... i've made it work!

For the real imagebutton I couldn't find any solution, since it'll always do the postback... but I'me not using a real imagebutton but, instead, i'm using a HyperLink associated with an image. I've made an invisible button wich does exactly what I want to be done by the hyperlink and then, as the NavigateURL property of the hyperlink, i put: "javascript:__doPostBack('Button1','')", beeing Button1 the invisible button! It works great!! :D

Hope i've made myself clear...

Thank you!
André Ribeiro wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-06-2008 3:28 AM
Hi again...
actually, the button can not be invisible... only disabled and disguised on the page...
Jim Wilson wrote re: ASP.NET AJAX and Windows Mobile - Huge Breakthrough
on 03-06-2008 6:16 AM
Andre;

That's fantastic!!

I'm very happy to hear that you were able to get everything going.

Congratulations,
Jim

Add a Comment

(required)  
(optional)
(required)  
Remember Me?