Solved

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

Posted on 2012-04-04
10
694 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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