当前位置:编程学习 > C#/ASP.NET >>

大神请进,请教fullcalendar日历控件$.post保存数据库问题


 viewDisplay: function (view) {
                    var viewStart = $.fullCalendar.formatDate(view.start, "yyyy-MM-dd");
                    var viewEnd = $.fullCalendar.formatDate(view.end, "yyyy-MM-dd HH:mm:ss");
                    //alert(viewStart+viewName); 
                    $("#calendar").fullCalendar('removeEvents');
                    $.getJSON('schedule/containEvents', { start: viewStart, end: viewEnd }, function (data) {
                        for (var i = 0; i < data.length; i++) {
                            var obj = new Object();
                            obj.id = data[i].id;
                            obj.title = data[i].title;
                            obj.description = data[i].description;
                            obj.color = data[i].color;
                            obj.remindertime = $.fullCalendar.parseDate(data[i].remindertime);
                            obj.messagenotice = data[i].messagenotice;
                            obj.description = data[i].description;
                            obj.start = $.fullCalendar.parseDate(data[i].start);
                            obj.end = $.fullCalendar.parseDate(data[i].end);
                            $("#calendar").fullCalendar('renderEvent', obj, true); //把从后台取出的数据进行封装以后在页面上以fullCalendar的方式进行显示 
                        }
                    });
                },
                selectable: true,
                selectHelper: true,
                select: function (start, end, allDay) {
                    $("#dvInput").dialog({
                        buttons: [{
                            text: "保存", click: function () {
                                var leixing = $('#leixing').val(), neirong = $('#neirong').val()
                                , title = '类型:' + leixing + '<br/>内容:' + neirong;
                                calendar.fullCalendar('renderEvent',
                                    {
                                        title: title,
                                        start: start,
                                        end: end,
                                        allDay: allDay
                                    },
                                    true // make the event "stick" 
                                ); //把刚输入的日程计划在页面上进行显示 

                                //alert($.fullCalendar.formatDate(start,'yyyy-MM-dd HH:mm:ss')); 
                                $.post("schedule/add", {//把刚输入的日程计划信息传到后台,保存到数据库 
                                    title: title,
                                    start: ($.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss')),
                                    end: ($.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss')),
                                    allDay: allDay
                                });

                                calendar.fullCalendar('unselect');
                                $(this).dialog("关闭");
                            }
                        }]
                    });
                }
            });

        });
//<div id="dvInput" title ="请输入内容" style ="display :none">
        类型:<input type ="text" id="leixing" /><br />
        内容:<input type ="text" id ="neirong" /><br />
        </div>
<div id='calendar'> </div>//


数据库是SQL2005,库是RiCheng,表名RCguanli,

有5个字段,ID主键,开始时间 结束时间 (datetime),类型 内容(varchar) --------------------编程问答-------------------- 首先  这个和JQ是没关系的,     你需要的是  在查看插入操作的时候出现的 参数问题 --------------------编程问答--------------------

$.post("schedule/add", {
//把刚输入的日程计划信息传到后台,保存到数库        
title: title,       
start: ($.fullCalendar.formatDate(start, 'yyyy-MM-dd hh:mm:ss')),         
end: ($.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss')),        
allDay: allDay}); 

把数据发送到了schedule/add,在add里接收数据写sql保存的数据库 --------------------编程问答--------------------
引用 2 楼 still_melody 的回复:
JavaScript code?123456$.post("schedule/add", {//把刚输入的日程计划信息传到后台,保存到数库        title: title,       start: ($.fullCalendar.formatDate(start, 'yyyy-MM-dd hh:mm:ss')),         end: ($.fullCale……


大神,怎么写?菜鸟求教 --------------------编程问答--------------------
引用 3 楼 zt061013 的回复:
引用 2 楼 still_melody 的回复:JavaScript code?123456$.post("schedule/add", {//把刚输入的日程计划信息传到后台,保存到数库        title: title,       start: ($.fullCalendar.formatDate(start, 'yyyy-MM-dd hh:mm:ss')), ……


我不知道你用的是什么框架。
你能找到add吗?

你就这一个页面吗?照着其他页面的写。或者你把其他页面保存数据的写法贴出来 --------------------编程问答--------------------
引用 4 楼 still_melody 的回复:
引用 3 楼 zt061013 的回复:
引用 2 楼 still_melody 的回复:JavaScript code?123456$.post("schedule/add", {//把刚输入的日程计划信息传到后台,保存到数库        title: title,       start: ($.fullCalendar.formatDate(start, 'yyyy-MM-dd hh:m……



    <script type='text/javascript'>

        $(document).ready(function () {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();

            var calendar = $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                dayNames: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
                dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
                today: ["今天"],
                firstDay: 1,
                buttonText: {
                    today: '今天',
                    month: '月',
                    week: '周',
                    day: '日',
                    prev: '上一个月',
                    next: '下一个月'
                },

                allDaySlot: true,
                selectable: true,
                selectHelper: true,
                aspectRatio: 2.7,
                editable: false,
                allDayDefault: true,
                editable: true,

                events: [
                       {
                           title: 'All Day Event',
                           start: new Date(y, m, 1)
                       },
                       {
                           title: 'Long Event',
                           start: new Date(y, m, d - 5),
                           end: new Date(y, m, d - 2)
                       },
                       {
                           id: 999,
                           title: 'Repeating Event',
                           start: new Date(y, m, d - 3, 16, 0),
                           allDay: false
                       },
                       {
                           id: 999,
                           title: 'Repeating Event',
                           start: new Date(y, m, d + 4, 16, 0),
                           allDay: false
                       },
                       {
                           title: 'Meeting',
                           start: new Date(y, m, d, 10, 30),
                           allDay: false
                       },
                       {
                           title: 'Lunch',
                           start: new Date(y, m, d, 12, 0),
                           end: new Date(y, m, d, 14, 0),
                           allDay: false
                       },
                       {
                           title: 'Birthday Party',
                           start: new Date(y, m, d + 1, 19, 0),
                           end: new Date(y, m, d + 1, 22, 30),
                           allDay: false
                       },
                       {
                           title: 'Click for Google',
                           start: new Date(y, m, 28),
                           end: new Date(y, m, 29),
                           url: 'http://google.com/'
                       }
                ],
                viewDisplay: function (view) {
                    var viewStart = $.fullCalendar.formatDate(view.start, "yyyy-MM-dd");
                    var viewEnd = $.fullCalendar.formatDate(view.end, "yyyy-MM-dd HH:mm:ss");
                    //alert(viewStart+viewName); 
                    $("#calendar").fullCalendar('removeEvents');
                    $.getJSON('schedule/containEvents', { start: viewStart, end: viewEnd }, function (data) {
                            for(var i=0;i<data.length;i++) {  
                                var obj = new Object();  
                                obj.id = data[i].id;  
                                obj.title = data[i].title;                 
                                obj.description = data[i].description;          
                                obj.color = data[i].color;
                                obj.remindertime = $.fullCalendar.parseDate(data[i].remindertime);
                                obj.messagenotice = data[i].messagenotice;
                                obj.description = data[i].description;
                                obj.start = $.fullCalendar.parseDate(data[i].start);                 
                                obj.end = $.fullCalendar.parseDate(data[i].end); 
                                $("#calendar").fullCalendar('renderEvent',obj,true); //把从后台取出的数据进行封装以后在页面上以fullCalendar的方式进行显示 
                        }
                    });
                },
                selectable: true,
                selectHelper: true,
                select: function (start, end, allDay) {
                    $("#dvInput").dialog({
                        buttons: [{
                            text: "保存", click: function () {
                                var leixing = $('#leixing').val(), neirong = $('#neirong').val()
                                , title = '类型:' + leixing + '<br/>内容:' + neirong;
                                calendar.fullCalendar('renderEvent',
                                    {
                                        title: title,
                                        start: start,
                                        end: end,
                                        allDay: allDay
                                    },
                                    true // make the event "stick" 
                                ); //把刚输入的日程计划在页面上进行显示 

                                //alert($.fullCalendar.formatDate(start,'yyyy-MM-dd HH:mm:ss')); 
                                $.post("schedule/add", {//把刚输入的日程计划信息传到后台,保存到数据库 
                                    title: title,
                                    start: ($.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss')),
                                    end: ($.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss')),
                                    allDay: allDay
                                });

                                calendar.fullCalendar('unselect');
                                $(this).dialog("关闭");
                            }
                        }]
                    });
                }
            });

        });
    </script> 

<style type='text/css'>

body {
margin-top: 40px;
text-align: center;
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}

#wrap {
width: 1100px;
margin: 0 auto;
}

#external-events {
float: left;
width: 150px;
padding: 0 10px;
border: 1px solid #ccc;
background: #eee;
text-align: left;
}

#external-events h4 {
font-size: 16px;
margin-top: 0;
padding-top: 1em;
}

.external-event { /* try to mimick the look of a real event */
margin: 10px 0;
padding: 2px 4px;
background: #3366CC;
color: #fff;
font-size: .85em;
cursor: pointer;
}

#external-events p {
margin: 1.5em 0;
font-size: 11px;
color: #666;
}

#external-events p input {
margin: 0;
vertical-align: middle;
}

#calendar {

width: 100%;
        
}

</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <div class="易做图">
        <div class="易做图Left">
        </div>
        <div class="易做图Content">
           
             <asp:LinkButton ID="lbAdd" CssClass="icon_add firstebox" runat="server"    isiframe="true" modal="true" xheight="400" xwidth="500"
               href="WebForm1.aspx">新增</asp:LinkButton>
             <asp:LinkButton ID="lbSearch" CssClass="icon_search firstebox" runat="server"  isiframe="true" modal="true" xheight="300" xwidth="400"
                 >查询</asp:LinkButton>
             <asp:LinkButton ID="LinkButton1" CssClass="icon_help firstebox" runat="server"  isiframe="true" modal="true" xheight="300" xwidth="400"
                 >统计</asp:LinkButton>
            
        </div>
        <div class="易做图Right">
        </div>
        <div class="clear">
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div id="dvInput" title ="请输入内容" style ="display :none">
        类型:<input type ="text" id="leixing" /><br />
        内容:<input type ="text" id ="neirong" /><br />
        </div>
<div id='calendar'> </div>
</asp:Content>


这是我的全部代码,现在就是不知道怎么把text里面的内容保存到数据库中....
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,