[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2012-04-04
10
Medium Priority
?
702 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 200 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 1800 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 200 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 1800 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 1800 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

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!

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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