I have two user controls in my ASP.Net project, one that is explictly for use with Internet Explorer 6 (IE6) and another that should be used when the user’s browser is not IE6.
How would I go about setting it up so that this happens; is this something I can put in a master page?
You can achieve this by using the
Browserproperty of theHttpRequestobject.Your page can either have both user-controls sited at design time, then at run time, you inspect the
Request.Browserproperty to determine the client’s browser and programmatically hide the user-control you don’t want the user to see.Alternatively, you can instantiate and render the correct user-control (again, after inspecting the
Request.Browserproperty) purely from your server-side code.For example, running the following code:
In a “standard” ASPX page displays:
when run in Internet Explorer 7, and:
(when run in Firefox)
So, you could have code something like the following in the web-page that you want to add this functionality to: