Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
Does your browser support the UpdatePanel? Test it programmatically. Get IE, Firefox, and Opera to work with the UpdatePanel. - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.

News

Visual Studio Magazine Column Personal Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

Does your browser support the UpdatePanel? Test it programmatically. Get IE, Firefox, and Opera to work with the UpdatePanel.

Original post: http://morewally.com/cs/blogs/wallym/archive/2006/09/24/371.aspx

 I wrote the following simple code to test to see if a browser supports the UpdatePanel, which is a control on the server, that provides Ajax support and is a part of the ASP.NET 2.0 Extensions for AJAX.  This code doesn't test for Javascript, ActiveX, or other features, it just tests the browser version.  Basically, the test is for Internet Explorer 6 or later, Firefox 1.5 or later, and Safari, though I don't think Safari works with the UpdatePanel at this point in time.  I test this with Opera for Windows, and I got the full postback.  I ran this against IE and I got the async postback.  Both were behaviors that I expected.  If you have any suggestions, please let me know.  I'm always trying to learn something new.

Another part of my test is in the Page_PreInit() method, I put in a call along the lines of

protected void Page_PreInit(object sender, EventArgs e)

{

if ( true == IsValidForUpdatePanel() )

{

      ScriptManager1.EnablePartialRendering = true;

      ScriptManager1.RegisterAsyncPostBackControl(this.btnSearch);

}

else

{

      ScriptManager1.EnablePartialRendering = false;

}

}

 

public static bool IsValidForUpdatePanel()

    {

        bool IsValid = false;

        try

        {

            IsValid = IsIE6OrLater() || IsFF15OrLater() || IsSafari();

        }

        catch

        {

            IsValid = false;

        }

        finally

        {

         }

        return (IsValid);

    }

    private static bool IsIE6OrLater()

    {

        return ((HttpContext.Current.Request.Browser.IsBrowser("IE")) &&

            (HttpContext.Current.Request.Browser.MajorVersion >= 6 ));

    }

    private static bool IsFF15OrLater()

    {

        return ((HttpContext.Current.Request.Browser.IsBrowser("Firefox")) &&

            ((HttpContext.Current.Request.Browser.MajorVersion == 1) &&

            (HttpContext.Current.Request.Browser.MinorVersion == .5) ||

            (HttpContext.Current.Request.Browser.MajorVersion >= 2)));

    }

    private static bool IsSafari() // <-- The  Safari is currently not supported in the latest CTP.

    {

        return (HttpContext.Current.Request.Browser.IsBrowser("Safari"));

    }

Posted: Sep 27 2006, 07:21 AM by Wallym | with 1 comment(s)
Filed under: ,

Comments

No Comments