Browser detect/if else formatting in ASP???

Hi, I'm ASP.NET stupid and need to do this:

<%
IF BROWSER IS IE4+{
%>
    BUNCH OF REGULAR HTM HERE
<%
} else {
%>
    OTHER HTML HERE
<%
}
%>

I need the browser detect code AND also the HOW you lay all that out in asp.
i.e....
if () {
}else{
}          I don't even know if that's proper format in ASP????????

Thanks!
-Sam
LVL 16
sam85281Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sagacitysolutionsCommented:
Is your page an ASP page or an ASP.Net page,

The file extension would tell you this  .asp or .aspx

Jeff CertainCommented:
Disclaimer: this was passed on to me by another developer and I haven't tried it yet... but it should do what you're after...

You put this into your web.config file and ASP.net will adjust the HTML (3.2 or
4.0) based on the user's browser.

<browserCaps>
            <!--NETSCAPE 6 and 7 //-->
            <case match="^Mozilla/5\.0 \([^)]*\)(Gecko/[-\d]+)?Netscape[6|7]/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)).*">
                tagwriter=System.Web.UI.HtmlTextWriter
                browser=Netscape
                version=${version}
                majorversion=${major}
                minorversion=${minor}
                frames=true
                tables=true
                cookies=true
                javascript=true
                javaapplets=true
                ecmascriptversion=1.5
                w3cdomversion=1.0
                css1=true
                css2=true
                xml=true
            </case>
            <!-- MOZILLA //-->
            <case match="^Mozilla/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)).*">
                <case match="^[5-9]\." with="${version}">
                    tagwriter=System.Web.UI.HtmlTextWriter
                </case>
            </case>
            <!--OPERA 5+//-->
             <case match="Opera[/](?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*))">
                 <filter match="[4-9]" with="${major}">
                     <filter match="[5-9]" with="${major}">
                        tagwriter=System.Web.UI.HtmlTextWriter
                     </filter>
                 </filter>
             </case>
        </browserCaps>

Otherwise, you can use Request.Browser to determine what browser is being used and react accordingly.
sam85281Author Commented:
It's asp.net

I finally got something to work (after 1000 years of messin' with it)

<%
dim USER_AGENT, IS_IE
USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
IS_IE = InStr(USER_AGENT,"MSIE")
if IS_IE then
%>
     <html code here>
<%
else
%>
     <more html code here>
<%
end if
%>

I like it because it's simple, and like I said I'm an asp idiot and don't plan on switching from php anytime soon.
Only thing that code is missing is Version Detection.

If you can tell me a SIMPLE way to add that to what I have, that would be cool.

Otherwise I'll just leave it since I think anyone using IE V3 or less should have their computer priveleges revoked! :)

Thanks,
-Sam
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Jeff CertainCommented:
Sam,
 Request.Browser.Version will give you the version ;)
sam85281Author Commented:
Like I said...I'm REALLY ASP DUMB! :)

Can you show me how I would add that to my code above?

Thanks,
-Sam
Jeff CertainCommented:
<%
dim USER_AGENT, IS_IE
USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
IS_IE = InStr(USER_AGENT,"MSIE")
if IS_IE then
  if Request.Browser.Version > 3 Then
    %>
      <html code here>
    <%
  else
    %>
      <html code here>
    <%
  end if
else
%>
     <more html code here>
<%
end if
%>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.