1

I'm new to Jquery .I want to display daily reports in JQuery calender control but I'm failing to load data dynamically from data base any one please help me

<script>

$(document).ready(function() {

    $('#calendar').fullCalendar({
        defaultDate: '2014-11-12',
        editable: true,
        eventLimit: true, // allow "more" link when too many events
        events: [
            {
                title: 'All Day Event',
                start: '2014-11-01'
            },
            {
                title: 'Long Event',
                start: '2014-11-07',
                end: '2014-11-10'
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: '2014-11-09T16:00:00'
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: '2014-11-16T16:00:00'
            },
            {
                title: 'Conference',
                start: '2014-11-11',
                end: '2014-11-13'
            },
            {
                title: 'Meeting',
                start: '2014-11-12T10:30:00',
                end: '2014-11-12T12:30:00'
            },
            {
                title: 'Lunch',
                start: '2014-11-12T12:00:00'
            }

        ]
    });

});

Then please tell me how to load this title and start dynamically from database in asp.net

1 Answer 1

1

You have to implement rest service and call it using AJAX. The most common way is create ApiController (if you are using MVC) or add ASMX Service for WebForms. You also able to import WebApi to WebForms project via NuGet.

The full explanation is too long. I'll give you some snippets:

Configure route table. Insert {action} placeholder in routeTemplate

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

Create ApiController method:

    [HttpGet]
    public List<CalendarEvent> GetEvents(int count)
    {
        return new List<CalendarEvent>();
    }

Call your api method with Jquery and get JSON:

        $.getJSON('http://yoursite.com/api/GetEvents', {
            count: 5
        }, function (data) {
            var jsonData = data;
        });
Sign up to request clarification or add additional context in comments.

2 Comments

Isn't there any simple way by using simple for loop ?
@Lax_me if you want to fetch data from server you don't need loops. You need to call server method from client-side. Get jsondata and set it to calendar events property

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.