Solved

Problems with AJAX on WINCE and IE 4.01

Posted on 2009-04-05
9
478 Views
Last Modified: 2012-05-06
Experts,

I have a web page that contains several user defined controls inside an update panel.  When one of them is updated and a TAB is pressed, a postback is automatically generated.  Code on the server side is supposed to populate several textboxes if the data item is found and then set the focus to a specific textbox on the form (inside the update panel).  In most browsers this worked as expected.  However, the ultimate target is a barcode scanner based on a PocketPC and no matter what I do, I can't seem to get it to return from the postback and have the focus in the field where I set it.  

The OS is WinCE and the browser identifies itself as IE 4.01.  The browser capabilities indicate that Javascript is supported.  Placing a <noscript> tag on the form does not have the javascript code inside run but then I am having problems getting other script to run on that device.  Unless I am mistaken, Javascript *should* be supported and enabled on this device.

I have tried adding javascript event handlers for before and after postback to the form.  In my test, I just fire alerts indicating which handler has been called.  Both fire just fine when I test from desktop machines running IE 6.  Again, when I run from the scanner I don't get anything.

I cannot just mandate the client update the barcode scanner.  I need something that will help me code around this problem and QUICKLY as I am in a severe time crunch on this one.  I really need an answer by Noon Eastern U.S. time on Monday.

Thanks in Advance,
Gandalf
0
Comment
Question by:gandalf97
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24076885
ermm. Did you just write that script placed inside noscript tags did not run???
If it did it would be fairly miraculous.

Anyway, can you post the code you are trying to execute?

If it uses xmlhttp, I am pretty sure it is not supported in IE4
Iframes are supported so perhaps you would want to try to post to hidden iframes
0
 
LVL 2

Author Comment

by:gandalf97
ID: 24077460
LOL...  I meant that the *text* I put in the noscript tag didn't show up which leads me to believe that Javascript is enabled.  I am also getting an alert to fire each time the page loads, including after postback.

I did include some script in the code window.  I'm trying to move things around and see if putting the script in the <head> will make any difference.  It's been a year since my job focused on Javascript and I am rusty on the finer points.

Are you saying that IE4 doesn't support AJAX at all?  So what is going on with the pages?  How is the markup being generated when the page is posted back?  Can you send me a pointer to something that talks about AJAX being supported or not on IE4?

Thanks for posting.  I do have a small extension of a couple of hours but this is still time sensitive.

Regards,
Gandalf

<head id="Head1" runat="server">
    <title>Inventory Withdrawl</title>
    
    <script type="text/javascript">
      alert("Page being loaded."); //20090406 Msg prints out on every page load on all devices.
      
          function pageLoad() {
 	    //20090403 1619.  Msg prints out *every* time the page loads, including after postback. (IE6)
 	    //20090406 0921.  Msg does NOT print out AT ALL on Symbol. (IE 4.01)
 	    alert("Page should be loaded.");
 	  }
 
    </script>
</head>
 
Additional Script:  (This is all in the body)
 
    <script type="text/javascript">
 	  //alert("Stuff Should be loaded");
 	  var oHiddenDiv
 	  var oParent
 	  var oTarget
 	  oHidNextFocus = document.getElementById("hidNextFocus");
 	  //foo = oHiddenDiv.InnerText;
 	  //alert(oHidNextFocus.value);
 	  //oParent = 
 	  oTarget = document.getElementById(oHidNextFocus.value);
 	  alert(oTarget.id);
 	  oTarget.focus();
 	  //oTarget = document.getElementById("");
 	  //foo.value = "ssss";
 
//20090406 0952 Commented out pageLoad here and moved it to the head.
// 	  function pageLoad() {
 	    //20090403 1619.  Msg prints out *every* time the page loads, including after postback.
 	    //20090406 0921.  Msg does NOT print out AT ALL on Symbol.
// 	    alert("Page should be loaded.");
// 	  }
 	  var prm = Sys.WebForms.PageRequestManager.getInstance();
      prm.add_beginRequest(BeginRequestHandler);
      prm.add_endRequest(EndRequestHandler);
 
      function BeginRequestHandler(sender, args) {
        // This code is executed before an async. postback
        alert("before postback");
      }
      
      function EndRequestHandler(sender, args) {
        // This code is executed after a successful async. postback 
        alert("after successful postback");
        oTarget = document.getElementById(oHidNextFocus.value);
 	    //alert(oTarget.id);
 	    oTarget.focus();
      }
      
      //20090406 EAS - Below line only prints when page first loaded and before msg from pageLoad()
      alert("This should print no matter what.");
    </script>

Open in new window

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24077620
this COULD have told you

http://en.wikipedia.org/wiki/XMLHttpRequest

// Provide the XMLHttpRequest class for IE 5.x-6.x:
if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() {
  try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
  throw new Error( "This browser does not support XMLHttpRequest." )
};

except IE4 does not support try/catch either

However
Sys.WebForms.PageRequestManager

looks to me like an embedded activeX object

You might also want to add
if (document.all &&!document.getElementById) document.getElementById = function(id) { return document.all(id) }

to the top of the page
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:gandalf97
ID: 24077985
Thanks for the quick response!

Thanks for the pointer to the Wiki article.  That will help me with the conversation I will need to have with my boss.  I need to be able to show her things like that.

I am working with ASP.NET (VB) 2.0 and the MS AJAX toolkit.  The AJAX piece is so I can do partial postbacks and only update a couple of controls on the screen.  This all seems to work the way I expect it to on the desktop (IE 6) but not the barcode scanner (IE4).  So, I am not sure of the mechanics but when the barcode scanner scans a work order, the WO is looked up and fields are populated just like on the desktop.  I can't say whether AJAX was ignored and the whole thing reloaded or not.  It is hard for me to tell.  I just know that it seems that some script is running and some is being ignored.

I will try adding that if(document.all....) code.  Should I add it near that alert in the head?  What is it supposed to do?

At this point, I will be happy if after a postback I can detect the browser and get a piece of javascript to run that sets focus to the part# text box.  Once I can get the alert to fire after postback, I know how to code setting the focus.

Thanks again.

Gandalf
0
 
LVL 2

Author Comment

by:gandalf97
ID: 24078010
Question:

I pasted: if (document.all &&!document.getElementById) document.getElementById = function(id) { return document.all(id) }

into my code.  It doesn't appear to do anything when I paste it right after the first alert.  Do I need to move it?

Regards,
Gandalf
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24078400
It implements the getElementById for IE4 if it does not exist. I it does not exist, then none of your code would work even with ok postback
It can be pasted anywhere, but right after the openeing script tag is a good place
0
 
LVL 2

Author Comment

by:gandalf97
ID: 24080569
Ok.  Thanks.  I put it in and it doesn't seem to make a difference.  I am still just getting the "page being loaded" alert when the page first loads and after the postback.  (On the IE4 machine).

Any further suggestions?

Regards,
Gandalf
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24080616
Sorry, no. last time I used IE4 was like a few years before the change of the millennium
0
 
LVL 2

Author Closing Comment

by:gandalf97
ID: 31566841
I still have trouble accepting that IE4 on a mobile device doesn't support what I was trying to do.  However, this was helpful in moving me down the road to an answer and I appreciate the help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices. Find out how to create a mobile email signature with this guide.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question