Solved

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

Posted on 2012-04-04
10
690 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 6

Assisted Solution

by:ingriT
ingriT earned 50 total points
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 450 total points
Comment Utility
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
Comment Utility
Ok, I will try the above and let you know if that works.
0
 
LVL 6

Expert Comment

by:ingriT
Comment Utility
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
Comment Utility
Thanks  guys !
0
 

Author Comment

by:amucinobluedot
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now