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. Enjoy
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"));
}