Friday, 21 August 2015

ASP.NET AJAX doesn't work on iPhone or iPad (Sys.WebForms object is undefined)

We've had a problem recently whereby iPhones and iPads weren't using AJAX correctly.

When you check this using JavaScript the Sys.WebForms object is undefined.

There are several documents saying how to resolve this by overriding OnInit on the page however we found it simpler to just update the browser definition file.

The capability that seems to be required for AJAX to work correctly (and for Sys.WebForms to be available) is supportsCallback

Here's what we have in the apple.browser definition file.

<browsers>
  <!-- Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3  -->
  <gateway id="iPhone" parentID="Safari">
    <identification>
      <userAgent match="iPhone" />
    </identification>
    <capabilities>
      <capability name="mobileDeviceModel"               value="iPhone" />
      <capability name="mobileDeviceManufacturer"        value="Apple" />
      <capability name="isMobileDevice"                  value="true" />
      <capability name="browser"                         value="Safari" />
      <capability name="type"                            value="Safari${major}" />
      <capability name="supportsCallback"                value="true" />
      <capability name="javascript"                      value="true" />
      <capability name="layoutEngine"                    value="WebKit" />
    </capabilities>
  </gateway>
  <!-- Mozilla/5.0 (iPad; CPU OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H143 Safari/600.1.4 -->
  <gateway id="iPad" parentID="Safari">
    <identification>
      <userAgent match="iPad" />
    </identification>
    <capabilities>
      <capability name="mobileDeviceModel"               value="iPad" />
      <capability name="mobileDeviceManufacturer"        value="Apple" />
      <capability name="isMobileDevice"                  value="true" />
      <capability name="browser"                         value="Safari" />
      <capability name="type"                            value="Safari${major}" />
      <capability name="supportsCallback"                value="true" />
      <capability name="javascript"                      value="true" />
      <capability name="layoutEngine"                    value="WebKit" />
    </capabilities>
  </gateway>
</browsers>

No comments:

Post a Comment