format of URL with asp variables - works in Firefox, not IE

T

Tom Petersen

I must have the format of the below line wrong for IE:

click <a href="cal.asp?sdate=<% =strDate1 %>&location=<% =strLocation
%>&eTime=<% =strDate2 %>">here</a> to add this information to your
Calendar<br>

When I hover my mouse over the link, the status bar at the bottom of the
page for IE says: shortcut to 2006 11:00 AM
With Firefox I get: http://sd-school/forms/cal.asp?sdate=10/18/2006 10:00
AM&location=Library&eTime=10/18/2006 11:00 AM

The form works in Firefox, which is what I use for testing. So either the
format is wrong, or IE doesn't like the spaces or something. It doesn't
matter which dates I use, I get the same results.

Any ideas?
 
B

Bob Barrows [MVP]

Tom said:
I must have the format of the below line wrong for IE:

click <a href="cal.asp?sdate=<% =strDate1 %>&location=<% =strLocation
%>&eTime=<% =strDate2 %>">here</a> to add this information to your
Calendar<br>

When I hover my mouse over the link, the status bar at the bottom of
the page for IE says: shortcut to 2006 11:00 AM
With Firefox I get: http://sd-school/forms/cal.asp?sdate=10/18/2006
10:00 AM&location=Library&eTime=10/18/2006 11:00 AM

The form works in Firefox, which is what I use for testing. So
either the format is wrong, or IE doesn't like the spaces or
something. It doesn't matter which dates I use, I get the same
results.

Any ideas?
Use Server.urlencode to fix the querystring part of the url.
 
T

Tom Petersen

That sounds like what I need, but I am having problems with the syntax of
this too. My IDE doesn't like the format, I think the <% %> are throwing it
off.

I think I am close with this:
strURL = "<% =strDate1 %>&location=<% =strLocation %>&eTime=<% =strDate2 %>"
strEncodedURL = Server.URLencode(strURL)
click <a href="cal.asp?sdate=& strEncodedURL">here</a> to add this
information to your Calendar<br>

or maybe this:
strURL = "cal.asp?sdate=<% =strDate1 %>&location=<% =strLocation %>&eTime=<%
=strDate2 %>"
strEncodedURL = Server.URLencode(strURL)
click <a href="& strEncodedURL">here</a> to add this information to your
Calendar<br>

It seems with the <% commands it doesn't know where asp ends and html
begins, neither do I! :)
 
B

Bob Barrows [MVP]

All server-side functions need to be inside the server-side script block
markers. Anything inside <%%> happens at the server. Here is an example:

<a href="cal.asp?sdate=<%= Server.UrlEncode(strDate1) %>&location=

To see where server-side ends and client-side begins, run the page and View
Source.
 
M

Mark Schupp

<%
strEncodedURL = "cal.asp?sdate=" & Server.URLencode(strDate1) & _
"&location=" & Server.URLencode(strLocation) & _
"&eTime=" & Server.URLencode(strDate2)
%>
click <a href="<%=strEncodedURL%>">here</a> to add this
 
T

Tom Petersen

Thanks! That corrects my syntax problem but IE still doesn't like
something. I may rethink how I am passing the variables to avoid 'special
characters' and format the date and time and not include spaces...

Response.Write strEncodedURL output:

cal.asp?sdate=10%2F18%2F2006+8%3A00+AM&location=Library&eTime=10%2F18%2F2006
+9%3A00+AM

IE: hyperlink value
http://sd-school/forms/cal.asp?sdate=10/18/2006+8:00+AM&location=Library&eTime=10/18/2006+9:00+AM
Firefox: hyperlink value
http://sd-school/forms/cal.asp?sdate=10/18/2006+8:00+AM&location=Library&eTime=10/18/2006+9:00+AM

The error with IE is:
Internet Explorer cannot download 00+AM from SD-school, where as Firefox
opens the outlook ready appointment screen where I just have to hit save and
close to add it to my calendar.
 
M

Mark Schupp

I think you are confusing hyperlink problems with content type problems.

What does cal.asp do? It appears that the browser is expected to open a
helper app (as you would expect Excel to open for an XLS file). This can be
dependant on the helper function being configured properly under IE.
 
T

Tom Petersen

It's not pretty, but it creates a calendar file for Outlook:

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library" -->


<%
'server.execute "../header.htm"

od = Request.QueryString("sdate")
et = Request.QueryString("eTime")
set oShell = CreateObject("WScript.Shell")
atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_
"Control\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
nd = dateadd("n", offsetMin, od)
ed = dateadd("n", offsetMin, et)
' Response.Write("Current = " & od & "<br>UTC = " & ed)

strLocation = Request.QueryString("location")
strSubject = "I-request"
strDescription = "test"





' -- Format it properly as YYYYMMDDThhmmssZ

if Month(nd) < 10 Then
strMonth = "0" & Right(Month(nd), 1)
Else strMonth = Month(nd)
End if
if Day(nd) < 10 Then
strDay = "0" & Right(Day(nd), 1)
Else strDay = Day(nd)
End if

if Hour(nd) < 10 Then
strHour = "0" & Right(Hour(nd), 1)
Else strHour = Hour(nd)
End if

if Minute(nd) < 10 Then
strMinute = "0" & Right(Minute(nd), 1)
Else strMinute = Minute(nd)
End if

if Month(ed) < 10 Then
streMonth = "0" & Right(Month(ed), 1)
Else streMonth = Month(ed)
End if

if Day(ed) < 10 Then
streDay = "0" & Right(Day(ed), 1)
Else streDay = Day(ed)
End if
if Hour(ed) < 10 Then
streHour = "0" & Right(Hour(ed), 1)
Else streHour = Hour(ed)
End if

if Minute(ed) < 10 Then
streMinute = "0" & Right(Minute(ed), 1)
Else streMinute = Minute(ed)
End if
' response.write streMinute

If StrMonth = "01" Then
dts = 1
Elseif StrMonth = "02" Then
dts = 1
Elseif StrMonth = "03" Then
dts = 1
Elseif StrMonth = "04" Then
dts = 0
Elseif StrMonth = "05" Then
dts = 0
Elseif StrMonth = "06" Then
dts = 0
Elseif StrMonth = "07" Then
dts = 0
Elseif StrMonth = "08" Then
dts = 0
Elseif StrMonth = "09" Then
dts = 0
Elseif StrMonth = "10" Then
dts = 0
Elseif StrMonth = "11" Then
dts = 1
Elseif StrMonth = "12" Then
dts = 1
End if

strHour = strHour + dts
streHour = streHour + dts

if strHour < 10 Then
strHour = "0" & Right(strHour, 1)
End if
if streHour < 10 Then
streHour = "0" & Right(streHour, 1)
End if



dtStart = Right(Year(nd),4) & strMonth & strDay & "T" & strHour &
strMinute & "00" & "Z"
dtEnd = Right(Year(ed),4) & streMonth & streDay & "T" & streHour &
streMinute & "00" & "Z"

' Response.Write dtStart & vbCrLf & dtEnd & vbCrLf



strvCalendar = "BEGIN:VCALENDAR" & vbCrLf & _
"VERSION:1.0" & vbCrLf & _
"BEGIN:VEVENT" & vbCrLf & _
"DTSTART:" & dtStart & vbCrLf & _
"DTEND:" & dtEnd & vbCrLf & _
"LOCATION;ENCODING=QUOTED-PRINTABLE:" & strLocation & vbCrLf & _
"UID:" & strStart & strSubject & vbCrLf & _
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & strDescription & vbCrLf & _
"SUMMARY;ENCODING=QUOTED-PRINTABLE:" & strSubject & vbCrLf & _
"PRIORITY:3" & vbCrLf & _
"END:VEVENT" & vbCrLf & _
"END:VCALENDAR" & vbCrLf

Response.ContentType = "text/x-vCalendar"
Response.AddHeader "Content-Disposition", _
"filename=Event" & "cal.vcs"
Response.Write strvCalendar
Response.End

' Response.Write dtStart

%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,158
Messages
2,570,882
Members
47,414
Latest member
djangoframe

Latest Threads

Top