Solved

Use ASP code A  if ipad is being used, else display code B

Posted on 2012-04-04
10
699 Views
Last Modified: 2012-04-04
I have an ASP/VB page and I have a form in that page, the form contains an html editor which works fine in computers but for some reason is very erratic when using ipad.
We want to display the code (A) with the form object HTML editor if user is NOT using an ipad, and display code (B) with the form element being  a simple text field is user IS using an ipad, something like:

<% if ipad being used %>
Code for HTML editor here
<%end%>
<% if ipad NOT being used %>
Code for text field here
<%end%>

I don't know how to detect what the user is using to browse and then how to do the IF statements to display one or the other object.

Hope that makes sense.
0
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 6

Assisted Solution

by:ingriT
ingriT earned 50 total points
ID: 37805927
You can get the useragent with this code:
Request.ServerVariables("HTTP_USER_AGENT")

Open in new window


And you can then check that for something in the useragent string of an iPad;
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

So, something like "iPad" would do I think.
0
 

Author Comment

by:amucinobluedot
ID: 37805939
Thanks, I guess that will answer 1/4 of the question. Ill wait for more feedback to later on assign points.
0
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 450 total points
ID: 37805952
Try this:

Function isIPad()
    If InStr(Request.ServerVariables("HTTP_USER_AGENT"), "iPad") > 0 Then
        isIPad = True
    Else
        isIPad = False
    End If
End Function

<%If Is_isIPad() then%>
    Code for HTML editor here
<%Else%>
    Code for text field here
<%End If%>

Open in new window

Hope that helps.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 6

Assisted Solution

by:ingriT
ingriT earned 50 total points
ID: 37805960
That's probably it, although I think you need to switch the if statement, to get the text field if iPad and HTML field if not.

<%If Is_isIPad() then%>
    Code for text field here    
<%Else%>
Code for HTML editor here
<%End If%>

Open in new window

0
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 450 total points
ID: 37805962
Sorry, correction code:

Function isIPad()
    If InStr(Request.ServerVariables("HTTP_USER_AGENT"), "iPad") > 0 Then
        isIPad = True
    Else
        isIPad = False
    End If
End Function

<%If isIPad() then%>
    Code for HTML editor here
<%Else%>
    Code for text field here
<%End If%>

Open in new window

0
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 450 total points
ID: 37805968
Ok, switch the If part. I mistaked it. If isIPad, then text field, else HTML editor. That's right. So definitive code:

Function isIPad()
    If InStr(Request.ServerVariables("HTTP_USER_AGENT"), "iPad") > 0 Then
        isIPad = True
    Else
        isIPad = False
    End If
End Function

<%If isIPad() then%>
    Code for text field here
<%Else%>
    Code for HTML editor here
<%End If%>

Open in new window

0
 

Author Comment

by:amucinobluedot
ID: 37805971
Ok, I will try the above and let you know if that works.
0
 
LVL 6

Expert Comment

by:ingriT
ID: 37805978
I wonder though, how you code the rest of your application/site, if you need someone else to write out the complete If statement that does a string compare?
0
 

Author Closing Comment

by:amucinobluedot
ID: 37807679
Thanks  guys !
0
 

Author Comment

by:amucinobluedot
ID: 37807684
btw .. if the page is ASP/Javascript what changes in the code that worked ?

---

Function isIPad()
    If InStr(Request.ServerVariables("HTTP_USER_AGENT"), "iPad") > 0 Then
        isIPad = True
    Else
        isIPad = False
    End If
End Function

<%If isIPad() then%>
    Code for text field here
<%Else%>
    Code for HTML editor here
<%End If%>


----
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Is your phone running out of space to hold pictures?  This article will show you quick tips on how to solve this problem.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question