如何使用ASP.NET在完整日历中加载数据 [英] How can I load data in full calendar using ASP.NET

查看:50
本文介绍了如何使用ASP.NET在完整日历中加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我不知道如何从MsSQL 2017数据库中将数据加载到完整日历中



请给我建议



谢谢



Maideen



什么我试过了:



Hi I do not have an idea how I can Load data into Full Calendar from MsSQL 2017 database

Pls advice me

Thank you

Maideen

What I have tried:

<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

推荐答案

(document).ready(function(){
var events = [];
(document).ready(function () { var events = [];


.ajax({
type: GET,
url:default.aspx / GetEvents,
success:function(dataDB){
.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);
},
错误:函数(错误){
alert('failed');
}
})

函数GenerateCalendar(事件){
.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) {


这篇关于如何使用ASP.NET在完整日历中加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆