search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Event Creation

Asked by Anonymous
6 years ago.

I'm implementing the Daypilot open source (lite) plugin in my web forms project and have followed the tutorial (https://aspnet.daypilot.org/lite-tutorial/) so far but am stuck on stage 6 for event creation. I've followed the steps of setting TimeRangeSelectedJavaScript to "document.location='Bookings.aspx?startingtime={0}';" and then in the Bookings.aspx page declare the startingtime variable in the page_load event.
DateTime startingTime;
if (Request.QueryString["startingtime"] != null)
startingTime = Convert.ToDateTime(Request.QueryString["startingtime"]);

This variable being passed is to fill the booking form with the start time and date from what was highlighted on the calendar plugin however, any amount of tinkering that I've done hasn't worked and altering the code leaves me with "cannot implicitly convert type string to system.datetime" errors or vice versa.

I would have thought just letting the textbox (txtStart.Text) equal to startingTime would carry over the value from the timetables.aspx page where the calendar plugin is.
Can anyone help me on this as I've been stuck on this part for some time and haven't made any progress?
Thanks in advance,
Mark

Answer posted by Dan Letecky [DayPilot]
6 years ago.

The latest version of DayPilot Lite exposes "start" and "end" variables (DayPilot.Date object). The string replacements ("{0}") are no longer applicable.

You can use the following TimeRangeSelectedJavaScript value instead:

"document.location='NewEvent.aspx?start=' + start + '&end=' + end;"

The tutorial is now updated:
https://aspnet.daypilot.org/handling-user-actions/

Thanks for reporting the issue!

Comment posted by Anonymous
6 years ago.

Thanks for the help,
I now get the start and end DateTimes appearing in the search bar when forwarded to the next page. I still have a problem however when setting an empty text box to the passed over values from the scheduler. When I try and add a line to let the StartingTime variable appear in a textbox I get "String was not recognized as a valid DateTime.'" errors
What should I add to the following code to assign the value to a textbox?
DateTime startingTime;
if (Request.QueryString["start"] != null)
startingTime = Convert.ToDateTime(Request.QueryString["start"]);

regards,
Mark

Comment posted by Dan Letecky [DayPilot]
6 years ago.

The default format used by DayPilot.Date.toString() method is the ISO 8601 format, e.g. "2018-02-13T00:00:00". The Convert.ToDateTime() method should be able to parse this string without any problem.

You can try to check if Request.QueryString["start"] holds the date in the expected format.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.