Monday, April 2, 2012

ASP.NET AJAX not working on Google Chrome and Safari - Update panel/Popup Extender.


Issue:
Recently i faced this issue when working with ASP.NET Ajax Updatepanel and Popup extender. The Popup was always visible and took a fixed space on the page like a normal div.

Solution:
Added the below javascript code to a .js file.
Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
if( navigator.userAgent.indexOf( 'WebKit/' ) > -1 )
{
  Sys.Browser.agent = Sys.Browser.WebKit;
  Sys.Browser.version = parseFloat( navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
  Sys.Browser.name = 'WebKit';
}

Refer the .js file in the ScriptManager.
<ajax:ToolkitScriptManager ID="scripts" runat="server" ScriptMode="Release" EnableHistory="true"
EnableSecureHistoryState="false" EnablePageMethods="True" CombineScripts="true"
OnAsyncPostBackError="Page_OnAsyncError" OnNavigate="OnHistoryNavigate">
    <Scripts>
        <asp:ScriptReference Path="~/js/webkit.js" />
    </Scripts>
</ajax:ToolkitScriptManager>

3 comments:

  1. great man... Saved my day.. my popup was not working on Safari and Chrome and I didn't know what to do. I was planning to replace the ASP.NET Ajax popup with jquery popup. But you saved my time and energy.. Thanks a lot..

    ReplyDelete
  2. Wonderful Guru. I was behind this for 2 days with no solution I could find googling. Your solution really saved me. Thanks a ton. keep sharing your genius.

    ReplyDelete
  3. still not working.
    We have menus in master pages and according to that respective page will be displayed but its work in IE and Mozilla.but after using above scripts still not working in Chrome and Safari.

    ReplyDelete