Solved

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

Posted on 2012-04-04
10
697 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Clear input text 15 33
AD Tool/Script Populate Security Groups Automatically 8 66
Read text on Table 7 46
IPAD vpn connection 3 32
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Learn about the eCommerce marketing trends for the year ahead.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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