This is a discussion on Need Help with ASP automatic .VCS file creation in Calendar App within the ASP Development forums, part of the Programming & Scripting category; the links in the program all say "?event_id=" so it seems like the original eventID initialization should work... but its ...
| |||||||
|
#11
| |||
| |||
| the links in the program all say "?event_id=" so it seems like the original eventID initialization should work... but its not... maybe i'll try printing the EventID variable into the vcs file to make sure its reading correctly.... otherwise i think i'll maybe ask somewhere else? |
|
#12
| ||||
| ||||
| What is displayed if you do this: Code: Dim EventID : EventID = Request.Querystring("event_id")
Response.Write("The EventID is: " & EventID)
Response.End
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#13
| |||
| |||
| okay, i figured out that the problem with referencing the event_id when creating a new event is that the event_id isn't created until the event is added. when I tried updating an existing event, it created the .vcs file correctly named. hmm... now i need to figure out how to call the generatecalendarfile subfunction when the event is added and the event exists. i wonder if that could also be the problem with my event time as well. |
|
#14
| |||
| |||
| Okay, So instead of calling the generateCalendarFile subroutine when the new event is being created, I've decided that I'm going to call it when anyone views an event, and I'm going to move the subroutine to the file event_view_popup_events.asp, which, in theory, will be called with the event_id value, so the .vcs file will be named correctly after initializing eventID with a CCGetFromGet or similar command, and it will also have all of the information that I was previously missing: time, description, etc., because the file was previously being created before the information had been saved from the new event form. The only problem I foresee with this is that I know it isn't "good" programming to re-write the file every time someone views the event details, but it should just overwrite the file that is already there, and .vcs files aren't more than a couple kilobytes to begin with. However, this will allow the user to download the latest file while viewing the event details and it will make sure that any updates are included. Plus, I'm way out of practice and I really just don't want to sift through this code anymore.... any thoughts? Last edited by MaxxMills84; June 11th, 2009 at 04:45 PM. |
|
#15
| ||||
| ||||
| I would put a link or a button on the "View Event" page that will do one of the following: 1. If you use a link, it will have a querystring appended (events.asp?event_id=13&do=download). Then check if CCGetFromGet("do","") = "download", generate the file. 2. If you use a button, set the value of the button to "download". Then check if CCGetFromPost("buttonname", "") = "download", generate the file. Does that make sense? |
|
#16
| |||
| |||
| Quote:
okay, so I got it to call the function in the right place. Now its correctly naming the .vcs files (which I changed to .ics per new 2.0 standards) and the files have all of the information getting written into them with no errors, but now I am having trouble getting the time and date in the correct format. here's the format that I already have the time and date in from the calendar program: 6/12/2009 1:00:00 PM here's the format that it should be in for the .ICS/.VCS file: 20090612T130000Z Here's the function that gets passed the two strings to turn into one: Code: function vCalDate(strDt, strTime)
dim arDate
arDate = split( strDt, "/" )
strDt = ""
dim j
for j = 0 to 2
if len( arDate( j ) ) = 1 then arDate( j ) = "0" & arDate( j )
strDt = strDt & arDate( j )
next
strTime = replace( strTime, ":", "" )
strTime = cLng( strTime ) + 40000
if strTime > 240000 then
strDt = cStr( cLng( strDt ) + 1 )
strTime = strTime - 240000
end if
strTime = cStr( strTime )
if len( strTime ) < 6 then
do until len( strTime ) = 6
strTime = "0" & strTime
loop
end if
vCalDate = strDt & "T" & strTime & "Z"
end function
i think all i'd have to do for the date is split the date by the forward slashes "/", then rearrange them without the slashes, and if any number is less than 10, append a "0" in front of it. for the time, if think I'd maybe need to check for AM vs PM somehow, and then convert to 24-hour time, and remove the colons ":" then put the two together with a T and Z as it currently does... I haven't done this kinda stuff in a while, could anyone give me a hand with this function? |
|
#17
| ||||
| ||||
| That function seems overly complicated. Try this: Code: function vCalDate(inp)
if IsDate(inp) then
d = CDate(inp)
ds = (Year(d) * 10000) + (Month(d) * 100) + Day(d)
ts = (Hour(d) * 10000) + (Minute(d) * 100) + Second(d)
vCalDate = (CStr(ds) & "T" & CStr(ts) & "Z")
end if
end function
document.write(vCalDate("6/12/2009 1:00:00 PM"))
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
| The Following User Says Thank You to Wolffy For This Useful Post: | ||
MaxxMills84 (June 12th, 2009) | ||
|
#18
| |||
| |||
| Quote:
1. This code did not account for AM/PM, because AM times should read as 0700 and this code would make them 700. 2. When importing the event into Outlook or iCal the events would be -4 hours off for some reason, even though the actual data of the .ics file was correct. So, here's how I corrected these problems: 1. Changed code by adding a simple if statement below: Code: function vCalDate(inp)
dim d, ds, ts
if IsDate(inp) then
d = CDate(inp)
ds = (Year(d) * 10000) + (Month(d) * 100) + Day(d)
if Hour(d) >= 10 then
ts = (Hour(d) * 10000) + (Minute(d) * 100) + Second(d)
else
ts = (Hour(d) * 10000) + (Minute(d) * 100) + Second(d)
ts = "0" & ts
end if
vCalDate = (CStr(ds) & "T" & CStr(ts))
end if
end function
2. The "Z" appended to the end of the time was actually telling the program that it should read it as UTC Z time zone which, on the east coast, is GMT -5 + 1 for daylight savings = -4 hours difference. Solution: remove "Z" from the end of the string. Now that the files are all being named correctly, the event data is correct, and I'm not getting any errors from Outlook or iCal when importing them, all that's left is to insert a link to the .ics file in the event details page. This should be the easy part but I'll let y'all know if I have any trouble with that too. Thanks again for the feedback |
|
#19
| |||
| |||
| Okay, So I'm now having trouble with how to create and display the link to the .ics file... The .asp code is very long and complex, but here's the portion where I called the function to generate the calendar file, because I'm sure that the data is loaded into the variables from the database at this point. Code: 'eventGrid Show Method @5-D26D48C9
Sub Show(Tpl)
Dim HasNext
If NOT Visible Then Exit Sub
Dim RowBlock
With DataSource
.Parameters("urlevent_id") = CCGetRequestParam("event_id", ccsGET)
.Parameters("seslocale") = Session("locale")
.Parameters("urlevents_category_id") = CCGetRequestParam("events_category_id", ccsGET)
End With
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeSelect", Me)
Set Recordset = DataSource.Open(Command)
If DataSource.Errors.Count = 0 Then IsDSEmpty = Recordset.EOF
Set TemplateBlock = Tpl.Block("Grid " & ComponentName)
If TemplateBlock is Nothing Then Exit Sub
Set RowBlock = TemplateBlock.Block("Row")
Set StaticControls = CCCreateCollection(TemplateBlock, Null, ccsParseOverwrite, _
Array(event_title, edit))
event_title.Value = Recordset.Fields("event_title")
edit_event.Parameters = CCGetQueryString("QueryString", Array("ccsForm"))
edit_event.Parameters = CCAddParam(edit_event.Parameters, "event_id", CCGetRequestParam("event_id", ccsGET))
edit_event.Page = "events.asp"
Set RowControls = CCCreateCollection(RowBlock, Null, ccsParseAccumulate, _
Array(event_date, event_time, event_time_end, category_id, user_id, event_desc, PanelLocation, PanelCost, PanelURL, PanelTextBox1, PanelTextBox2, PanelTextBox3, PanelTextArea1, PanelTextArea2, PanelTextArea3, PanelCheckBox1, PanelCheckBox2, PanelCheckBox3))
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShow", Me)
If NOT Visible Then Exit Sub
RowControls.PreserveControlsVisible
Errors.AddErrors DataSource.Errors
If Errors.Count > 0 Then
TemplateBlock.HTML = CCFormatError("Grid " & ComponentName, Errors)
Else
' Show NoRecords block if no records are found
If Recordset.EOF Then
TemplateBlock.Block("NoRecords").Parse ccsParseOverwrite
End If
HasNext = HasNextRow()
ForceIteration = False
Do While ForceIteration Or HasNext
If HasNext Then
event_date.Value = Recordset.Fields("event_date")
event_time.Value = Recordset.Fields("event_time")
event_time_end.Value = Recordset.Fields("event_time_end")
category_id.Value = Recordset.Fields("category_id")
user_id.Value = Recordset.Fields("user_id")
event_desc.Value = Recordset.Fields("event_desc")
event_Location.Value = Recordset.Fields("event_Location")
event_Cost.Value = Recordset.Fields("event_Cost")
event_URL.Value = Recordset.Fields("event_URL")
event_URL.Link = ""
event_URL.Page = Recordset.Fields("event_url")
event_TextBox1.Value = Recordset.Fields("event_TextBox1")
event_TextBox2.Value = Recordset.Fields("event_TextBox2")
event_TextBox3.Value = Recordset.Fields("event_TextBox3")
event_TextArea1.Value = Recordset.Fields("event_TextArea1")
event_TextArea2.Value = Recordset.Fields("event_TextArea2")
event_TextArea3.Value = Recordset.Fields("event_TextArea3")
event_CheckBox1.Value = Recordset.Fields("event_CheckBox1")
event_CheckBox2.Value = Recordset.Fields("event_CheckBox2")
event_CheckBox3.Value = Recordset.Fields("event_CheckBox3")
End If
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShowRow", Me)
RowControls.Show
If HasNext Then Recordset.MoveNext
ShownRecords = ShownRecords + 1
HasNext = HasNextRow()
Loop
StaticControls.Show
End If
generateCalendarFile
End Sub
'End eventGrid Show Method
Code: <html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>{event_name}</title>
<meta content="CodeCharge Studio 3.0.2.2" name="GENERATOR">
<link media="screen" href="Styles/{CCS_Style}/Style.css" type="text/css" rel="stylesheet">
<link media="print" href="ccsprint.css" type="text/css" rel="stylesheet">
<script language="JavaScript">
function parent_redirect(url) {
window.opener.location.href=url;
self.close();
}
</script>
</head>
<body>
<!-- BEGIN Grid eventGrid -->
<table class="Header" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="HeaderLeft"><img src="Styles/{CCS_Style}/Images/Spacer.gif" border="0"></td>
<th>{event_title}</th>
<td class="HeaderRight"><img src="Styles/{CCS_Style}/Images/Spacer.gif" border="0"></td>
</tr>
</table>
<table class="Grid" cellspacing="0" cellpadding="0">
<!-- BEGIN Row -->
<tr class="Row">
<td><b>{event_date}
<!-- BEGIN Label event_time -->, {event_time}<!-- END Label event_time -->
<!-- BEGIN Label event_time_end -->- {event_time_end} <!-- END Label event_time_end --></b><br>
<!-- BEGIN Label category_id --><b>{res:cal_category}:</b> {category_id}. <br>
<!-- END Label category_id --><b>{res:cal_addedby}:</b> {user_id}<br>
<br>
{event_desc}
<!-- BEGIN Panel PanelLocation --><br>
<br>
<b>{LabelLocation}:</b> {event_Location}<!-- END Panel PanelLocation -->
<!-- BEGIN Panel PanelCost --><br>
<br>
<b>{LabelCost}:</b> {event_Cost}<!-- END Panel PanelCost -->
<!-- BEGIN Panel PanelURL --><br>
<br>
<b>{LabelURL}:</b> <a href="{event_URL_Src}">{event_URL}</a><!-- END Panel PanelURL -->
<!-- BEGIN Panel PanelTextBox1 --><br>
<br>
<b>{LabelTextBox1}:</b> {event_TextBox1}<!-- END Panel PanelTextBox1 -->
<!-- BEGIN Panel PanelTextBox2 --><br>
<br>
<b>{LabelTextBox2}:</b> {event_TextBox2}<!-- END Panel PanelTextBox2 -->
<!-- BEGIN Panel PanelTextBox3 --><br>
<br>
<b>{LabelTextBox3}:</b> {event_TextBox3}<!-- END Panel PanelTextBox3 -->
<!-- BEGIN Panel PanelTextArea1 --><br>
<br>
<b>{LabelTextArea1}</b> {event_TextArea1}<!-- END Panel PanelTextArea1 -->
<!-- BEGIN Panel PanelTextArea2 --><br>
<br>
<b>{LabelTextArea2}:</b> {event_TextArea2}<!-- END Panel PanelTextArea2 -->
<!-- BEGIN Panel PanelTextArea3 --><br>
<br>
<b>{LabelTextArea3}:</b> {event_TextArea3}<!-- END Panel PanelTextArea3 -->
<!-- BEGIN Panel PanelCheckBox1 --><br>
<br>
<b>{LabelCheckBox1}:</b> {event_CheckBox1}<!-- END Panel PanelCheckBox1 -->
<!-- BEGIN Panel PanelCheckBox2 --><br>
<br>
<b>{LabelCheckBox2}:</b> {event_CheckBox2}<!-- END Panel PanelCheckBox2 -->
<!-- BEGIN Panel PanelCheckBox3 --><br>
<br>
<b>{LabelCheckBox3}:</b> {event_CheckBox3}<!-- END Panel PanelCheckBox3 --></td>
</tr>
<!-- END Row -->
<!-- BEGIN Panel edit -->
<tr class="Row">
<td align="right">
<div class="noprint"><a href="javascript:parent_redirect('{edit_event_Src}')">{res:cal_edit_event}</a></div>
</td>
</tr>
<!-- END Panel edit -->
<!-- BEGIN NoRecords -->
<tr class="NoRecords">
<td>{res:CCS_NoRecords}</td>
</tr>
<!-- END NoRecords -->
</table>
<!-- END Grid eventGrid -->
<br>
<div class="noprint" align="left"><a href="{close_link_Src}">{res:close_window}</a> <a href="{print_link_Src}">{res:print}</a></div>
</body>
</html>
![]() Basically, I just need the html to display a link in the form: Code: <a href="Event_{event_id}.ics">Click here to download the event into your Outlook calendar.</a>
|
|
#20
| ||||
| ||||
| I'm no ASP'er but I think the following should work: Code: <% Response.Write( "<a href="Event_" & event_id & ".ics">Click here to download the event into your Outlook calendar.</a>") %> |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calendar for date entry | alex motilal | Microsoft Access | 1 | March 3rd, 2009 09:59 AM |
| Access 2007 Calendar Year wrong | coolcatkelso | Microsoft Access | 3 | February 9th, 2009 08:04 AM |
| Custom Calendar Control | AOG123 | Access Database Samples | 6 | December 10th, 2008 05:34 PM |