473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

IE and Netscape compatibility for ASP.NET

Hi Everybody!
I have a browser compability issue with ASP.NET pages. I have created a
small web-site in ASP.NET, tested it with IE - all was well till then. Then
my client required me to test on other browsers as well such as Netscape and
Mozzila. The page gets displayed ont hem but the formatting goes for a toss!
Does anyone know a work around for it? I remember when we use to do ASP
programming - we use to write client side Javascript code to detect the
browser and then execute the appropiate sensitive piece of code for
different browsers. Does the same need to be done in ASP.NET or is there
some new concept as well?

Any help would be appreciated...

Thanks and Regards,
Ashwini
Nov 19 '05 #1
2 1133
Hi, Ashwini.

In ASP.NET, you can use Request.Browser to identify browser
capabilities, and redirect the user based on the results.

Here's a sample detection page.

detect.aspx:
------------------
<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
ltlBrowserName.Text = Request.Browser.Type & ", " & Request.Browser.Platform
ltlAllData.Text = "Type = " & Request.Browser.Type & "<br>"
ltlAllData.Text &= "Name = " & Request.Browser.Browser & "<br>"
ltlAllData.Text &= "Version = " & Request.Browser.Version & "<br>"
ltlAllData.Text &= "Major Version = " & Request.Browser.MajorVersion & "<br>"
ltlAllData.Text &= "Minor Version = " & Request.Browser.MinorVersion & "<br>"
ltlAllData.Text &= "Platform = " & Request.Browser.Platform & "<br>"
ltlAllData.Text &= "Is Beta = " & Request.Browser.Beta & "<br>"
ltlAllData.Text &= "Is Crawler = " & Request.Browser.Crawler & "<br>"
ltlAllData.Text &= "Is AOL = " & Request.Browser.AOL & "<br>"
ltlAllData.Text &= "Is Win16 = " & Request.Browser.Win16 & "<br>"
ltlAllData.Text &= "Is Win32 = " & Request.Browser.Win32 & "<br>"
ltlAllData.Text &= "Supports Frames = " & Request.Browser.Frames & "<br>"
ltlAllData.Text &= "Supports Tables = " & Request.Browser.Tables & "<br>"
ltlAllData.Text &= "Supports Cookies = " & Request.Browser.Cookies & "<br>"
ltlAllData.Text &= "Supports VB Script = " & Request.Browser.VBScript & "<br>"
ltlAllData.Text &= "Supports JavaScript = " & Request.Browser.JavaScript & "<br>"
ltlAllData.Text &= "Supports Java Applets = " & Request.Browser.JavaApplets & "<br>"
ltlAllData.Text &= "CDF = " & Request.Browser.CDF & "<br>"
End Sub
</script>
<html>
<body>
Your browser is: <asp:literal id="ltlBrowserName" runat="server" />
<p>
<b><u>Here is your browser's information:</u></b><br />
<asp:literal runat="server" id="ltlAllData" />
</body>
</html>
---------------

It's very easy to redirect based on the results of Request.Browser:

Dim browserType As String = Request.Browser.Type
If browserType = "Netscape" Then
response.redirect("PageForNetscapeUsers.aspx")
End if

You could also use a Case statement to determine different redirect pages,
based on the several possibilities you're interested in, if you're interested in
creating custom pages for more than one browser.

Your custom browser pages could just be the very same page,
copied to a different filename, with the @Page directive clienttarget
set to "downlevel" :

<%@ Page ClientTarget = "downlevel" %>

That will send HTML 3.2, instead of HTML 4, output to the browser,
and should eliminate your formatting problems.

If you take a look at your machine.config file for .NET 1.1, located at
drive:\WINDOWSInstallDirectory\Microsoft.NET\Frame work\v1.1.4322\CONFIG\machine.config
you'll see a lot of browser matches specified in the browserCaps section.

If you are using .NET 1.0, the file would be at

drive:\WINDOWSInstallDirectory\Microsoft.NET\Frame work\v1.0.3705\CONFIG\machine.config

If you are using .NET 1.0, the file would be at

drive:\WINDOWSInstallDirectory\Microsoft.NET\Frame work\v1.0.3705\CONFIG\machine.config

If you haven't modified the browserCaps section, by specifying a value for it in web.config,
you will be able to filter a Netscape browser, for example, ( or any browser listed )
by using the Type, Name, Major Version or Minor Version attributes obtained
with Request.Browser, per the script supplied.

..NET 2.0 changes the detection process slightly, and the location
of individual browser detection files, so I won't discuss it here.

Good luck, and let us know how you do!

Juan T. Llibre
ASP.NET MVP
===========
"Ashwini Khanna" <as********@hotmail.com> wrote in message news:Oi**************@TK2MSFTNGP14.phx.gbl...
Hi Everybody!
I have a browser compability issue with ASP.NET pages. I have created a
small web-site in ASP.NET, tested it with IE - all was well till then. Then
my client required me to test on other browsers as well such as Netscape and
Mozzila. The page gets displayed ont hem but the formatting goes for a toss!
Does anyone know a work around for it? I remember when we use to do ASP
programming - we use to write client side Javascript code to detect the
browser and then execute the appropiate sensitive piece of code for
different browsers. Does the same need to be done in ASP.NET or is there
some new concept as well?

Any help would be appreciated...

Thanks and Regards,
Ashwini

Nov 19 '05 #2
Hi Juan,
Thanks a lot! That was very helpful!

Ashwini
"Juan T. Llibre" <no***********@nowhere.com> wrote in message news:O%****************@TK2MSFTNGP14.phx.gbl...
Hi, Ashwini.

In ASP.NET, you can use Request.Browser to identify browser
capabilities, and redirect the user based on the results.

Here's a sample detection page.

detect.aspx:
------------------
<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
ltlBrowserName.Text = Request.Browser.Type & ", " & Request.Browser.Platform
ltlAllData.Text = "Type = " & Request.Browser.Type & "<br>"
ltlAllData.Text &= "Name = " & Request.Browser.Browser & "<br>"
ltlAllData.Text &= "Version = " & Request.Browser.Version & "<br>"
ltlAllData.Text &= "Major Version = " & Request.Browser.MajorVersion & "<br>"
ltlAllData.Text &= "Minor Version = " & Request.Browser.MinorVersion & "<br>"
ltlAllData.Text &= "Platform = " & Request.Browser.Platform & "<br>"
ltlAllData.Text &= "Is Beta = " & Request.Browser.Beta & "<br>"
ltlAllData.Text &= "Is Crawler = " & Request.Browser.Crawler & "<br>"
ltlAllData.Text &= "Is AOL = " & Request.Browser.AOL & "<br>"
ltlAllData.Text &= "Is Win16 = " & Request.Browser.Win16 & "<br>"
ltlAllData.Text &= "Is Win32 = " & Request.Browser.Win32 & "<br>"
ltlAllData.Text &= "Supports Frames = " & Request.Browser.Frames & "<br>"
ltlAllData.Text &= "Supports Tables = " & Request.Browser.Tables & "<br>"
ltlAllData.Text &= "Supports Cookies = " & Request.Browser.Cookies & "<br>"
ltlAllData.Text &= "Supports VB Script = " & Request.Browser.VBScript & "<br>"
ltlAllData.Text &= "Supports JavaScript = " & Request.Browser.JavaScript & "<br>"
ltlAllData.Text &= "Supports Java Applets = " & Request.Browser.JavaApplets & "<br>"
ltlAllData.Text &= "CDF = " & Request.Browser.CDF & "<br>"
End Sub
</script>
<html>
<body>
Your browser is: <asp:literal id="ltlBrowserName" runat="server" />
<p>
<b><u>Here is your browser's information:</u></b><br />
<asp:literal runat="server" id="ltlAllData" />
</body>
</html>
---------------

It's very easy to redirect based on the results of Request.Browser:

Dim browserType As String = Request.Browser.Type
If browserType = "Netscape" Then
response.redirect("PageForNetscapeUsers.aspx")
End if

You could also use a Case statement to determine different redirect pages,
based on the several possibilities you're interested in, if you're interested in
creating custom pages for more than one browser.

Your custom browser pages could just be the very same page,
copied to a different filename, with the @Page directive clienttarget
set to "downlevel" :

<%@ Page ClientTarget = "downlevel" %>

That will send HTML 3.2, instead of HTML 4, output to the browser,
and should eliminate your formatting problems.

If you take a look at your machine.config file for .NET 1.1, located at
drive:\WINDOWSInstallDirectory\Microsoft.NET\Frame work\v1.1.4322\CONFIG\machine.config
you'll see a lot of browser matches specified in the browserCaps section.

If you are using .NET 1.0, the file would be at

drive:\WINDOWSInstallDirectory\Microsoft.NET\Frame work\v1.0.3705\CONFIG\machine.config

If you are using .NET 1.0, the file would be at

drive:\WINDOWSInstallDirectory\Microsoft.NET\Frame work\v1.0.3705\CONFIG\machine.config

If you haven't modified the browserCaps section, by specifying a value for it in web.config,
you will be able to filter a Netscape browser, for example, ( or any browser listed )
by using the Type, Name, Major Version or Minor Version attributes obtained
with Request.Browser, per the script supplied.

.NET 2.0 changes the detection process slightly, and the location
of individual browser detection files, so I won't discuss it here.

Good luck, and let us know how you do!

Juan T. Llibre
ASP.NET MVP
===========
"Ashwini Khanna" <as********@hotmail.com> wrote in message news:Oi**************@TK2MSFTNGP14.phx.gbl...
Hi Everybody!
I have a browser compability issue with ASP.NET pages. I have created a
small web-site in ASP.NET, tested it with IE - all was well till then. Then
my client required me to test on other browsers as well such as Netscape and
Mozzila. The page gets displayed ont hem but the formatting goes for a toss!
Does anyone know a work around for it? I remember when we use to do ASP
programming - we use to write client side Javascript code to detect the
browser and then execute the appropiate sensitive piece of code for
different browsers. Does the same need to be done in ASP.NET or is there
some new concept as well?

Any help would be appreciated...

Thanks and Regards,
Ashwini

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some...
4
by: Federico Bari | last post by:
Good morning all from italy, i have probably a compatibility problem with a html/javascript page. The aim of the code of the file test.htm you find here following (copy the 3 files in the...
26
by: Roger Desparois | last post by:
Hi, I need help : I found the simplest and most precise way to open and close submenu layers. it works perfectly with IE, but for some odd reason NS won't recognize it. Can anyone tell me why...
3
by: VK | last post by:
<http://browser.netscape.com/ns8/> The biggest hecs: Two totally separate, including scripting, parsing engines: Mozilla/Firefox (called "Netscape") and Internet Explorer. User can choose any...
1
by: MLibby | last post by:
I'm a Netscape newbie and am using it for backward compatibility testing. How do I debug javascript in Netscape? I set Netscape as the default debugger (design mode | file | Browse With) and I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.