Reputation: 364
So i have a print this view button on jquery full calendar that takes the date ranges that are in the current view and generates a more printer friendly version of calendar. this is the beginning of controller.
public ActionResult PrintableCalendar(string start, string end)
{
DateTime StartTime = Convert.ToDateTime(start);
DateTime EndTime = Convert.ToDateTime(end);
EndTime = EndTime.AddDays(-1);
ClientContext clientContext = new ClientContext(WebConfigurationManager.AppSettings["SPSite"]);
Web site = clientContext.Web;
This is the button thats on the initial calendar
<input type="button" id="PrintView" name="PrintView" value="Print This View" />
this is the click function of the button. $('#PrintView').click(function () { var currentCalendarView = $('#calendar').fullCalendar("getView"); var startDate = currentCalendarView.visStart; var endDate = currentCalendarView.visEnd; window.open(@Url.Action("PrintableCalendar", "OnCall", new{start=startDate.toString(), end=endDate.toString()})); });
UPDATE...this is being called initially in the same view to generate the calendar
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
data: JSON.stringify(),
eventRender: function(event, element) {
element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());
},
events: "@(Url.Action("GetEvents", "OnCall"))",
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
</script>
Upvotes: 0
Views: 2063
Reputation: 3
You try this, it help you to call specific controller with action and parameter.
window.location.href = "@Url.Action("Action", "Controller")" +"/"+ parameter ;
Upvotes: 0
Reputation: 647
You are mixing JS with .Net parameters.
Try replacing your last line with
window.open('@Url.Action("PrintableCalendar", "OnCall", null)?start=startDate&end=endDate');
[EDIT AFTER YOU CORRECTED ME] (Forgot some quotes and the toDateString in the call)
window.open('@Url.Action("PrintableCalendar", "OnCall", null)?start=' + startDate.toDateString() + '&end=' + endDate.toDateString());
Upvotes: 1