IE 6 upgrade warning in your asp.net pages using C#

ASP.NET Comments Off on IE 6 upgrade warning in your asp.net pages using C#

IF IE6 does not deliver your pages as designed. you can force a small warning box to IE6 users to upgrade their browsers. The demo shown here is for one aspx page, you can include this in your master page to show throughout the site.

The tutorial is very simple

1. Add a panel in your aspx page with the warning message and default visibility to false.

2. Obtain the Browser and Browser version in the code behind file and check for IE 6. If it is IE6 then enable the visibility of the warning panel.

.aspx page

<form id="form1" runat="server">
 <div>
 <asp:Panel ID="warning_panel" runat="server" BackColor="#EBEBEB" BorderColor="#CC3300"
 BorderStyle="Dotted" BorderWidth="1px" Visible="False" Font-Names="Arial" Font-Size="11px">
 You are currently using Internet Explorer 6. Please upgrade your browser for
 better user experience. You can download the latest browsers from the following
 links.<br />
 <a href="http://www.microsoft.com/Windows/internet-explorer/default.aspx">INTERNET
 EXPLORER 8</a>&nbsp;,&nbsp;<a href="http://www.opera.com/browser/">Opera</a>&nbsp;,&nbsp;<a
 href="http://www.mozilla.com/en-US/">FireFox</a><br />
 </asp:Panel>
 </div>
 </form>

.cs file (code behind file)

protected void Page_Load(object sender, EventArgs e)
 {
 string browser;
 browser = System.Web.HttpContext.Current.Request.Browser.Browser.ToString();
 browser += System.Web.HttpContext.Current.Request.Browser.Version.ToString();
 if(browser=="IE6.0")
 {
 warning_panel.Visible = true;

 }

 }

 



Author

Search

Back to Top