Integrate jQuery Full Calendar in ASP.Net

Last Reply one month ago By dharmendr

Posted one month ago

Hi

I have no Idea how to load data into FullCalender control from MSSQL 2017 data using asp.net

It is my Code 

Pls advice me 

Thank  you

Maideen

<script>
    $(document).ready(function () {
        var events = [];
        $.ajax({
            type: "GET",
            url: "default.aspx/GetEvents",
            success: function (dataDB) {
                $.each(dataDB, function (i, v) {
                    events.push({
                        title: v.Subject,
                        description: v.Description,
                        start: moment(v.Start_Date),
                        end: v.End_Date != null ? moment(v.End_date) : null,
                        color: v.ThemeColor,
                        allday:v.isFullDay
                    });
                })
                GenerateCalendar(events);
            },
            error: function (error) {
                alert('failed');
            }
        })

        function GenerateCalendar(events) {
            $('#calendar').fullCalendar('destroy');
            $('#calendar').fullCalendar({
                contentHeight: 400,
                defaultDate: new date(),
                timeFormat: 'h(:mm)a',
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay,agenda'
                },
                eventLimit: true,
                eventColor: '#378006',
                events: events
            })

        }
        
    })

</script>    

 

    Private Sub GetEvents()
        Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString
        Dim query As String = "select * from CL_Events"
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand(query)
                cmd.CommandType = CommandType.Text
                cmd.Connection = con
                con.Open()
            End Using
        End Using
    End Sub
    Private Sub GetEvents()
        Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString
        Dim query As String = "select * from CL_Events"
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand(query)
                cmd.CommandType = CommandType.Text
                cmd.Connection = con
                con.Open()
                Using sdr As SqlDataReader = cmd.ExecuteReader()
                    While sdr.Read()

                    End While
                End Using
                con.Close()

            End Using
        End Using
    End Sub