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

How to display day, week, month and year view on selection of user choice?

Asked by Anvesh
10 years ago.

Hello,
I have integrated Day Pilot Calendar in to my application and I want to give a facility to user to select view. Like if user selects day view then it will display calendar in day view, if user selects week then it will display week and same for all month and year. So I wanted to know that how to give this ability on Asp.Net web forms. Most probably selection will be in dropdown form so if this is possible to do with Javascript then it's fine otherwise C# code will be good. Can I implement this one if yes then will you guys please provide me sample or and links to achieve this?

Thanks,
Anvesh

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

The best way is to add one control for each of the views (day/week/month) and hide all except of one.

1. You can do this by simply wrapping them in a div with style="display:none" and change this property.
2. You can use a tab control (e.g. from AJAX Control Toolkit - http://ajaxcontroltoolkit.codeplex.com/).
3. You can use multiple UpdatePanels.

There are a few related problems, though:

1. If the div with the control is hidden during initialization the position calculations will fail (it's not possible to get dimensions of an element hidden using display:none) and it will cause some problems, e.g. the scrollbar position will be reset and the background cells may not get initialized in the dynamic rendering mode in the Scheduler.

This can be fixed by only internal API calls at this moment. In the next release, it will be possible to show and hide the controls using client-side .show() and .hide() methods which will include the recalculation.

2. You will need to store the selected date separately (so the day doesn't get reset if you switch from day to week view and back).

3. You will need to refresh the events when switching the views.

A more elegant client-side solution is under way but it's not available yet.

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