0

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>
2
  • Did you set up that route with those custom parameters in your route.config file? Commented Mar 31, 2014 at 14:20
  • Its actually error trappping my page and telling me theres an error, i s that due to having another URL.action being called when page loads in a different script Commented Mar 31, 2014 at 14:29

2 Answers 2

1

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());
Sign up to request clarification or add additional context in comments.

Comments

0

You try this, it help you to call specific controller with action and parameter.

window.location.href = "@Url.Action("Action", "Controller")" +"/"+ parameter ;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.