0
<script>

    $(document).ready(function() {

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
        editable: true,

        events: [


                {
                    id: 1,
                    title: moo,
                    start: new Date(2013, m, 1)
                },
                {
                    id: 2,
                    title: 'Long Event',
                    start: new Date(y, m, d-5),
                    end: new Date(y, m, d-2)
                },
                {
                    id: 3,
                    title: 'Repeating Event',
                    start: new Date(y, m, d-3, 03, 0),
                    allDay: false
                }
            ]
        });

    });

</script>

http://resource.thaicreate.com/upload/stock/20130711105733.png?v=1001图像数据库

我想在事件中插入数据(数据库):[(javascript)。我的想法是使用linq foreach,但会将其发送到javascript标签事件,我听说使用json,但不知道如何使用它,因为它使用的不是。

我是泰国人。英语不熟练。我非常感谢大家。

protected void Page_Load(object sender, EventArgs e)

{

DataClasses1DataContext db = new DataClasses1DataContext();

var conn = from p in db.cars select p;

        foreach (car p in conn)
        {
            // I do not know how to go on
            //   {
             //   id: 4,
             //   title: 'fullmoon',
             //   start: new Date(y, m, d-3, 03, 0),
             //   allDay: false
             //  }
        }
4

1 回答 1

1

尝试使用 JavaScriptSerializer:

http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx

var conn = from p in db.cars select p;

JavaScriptSerializer jss = new JavaScriptSerializer();
var jsonCars = jss.Serialize(conn);
于 2013-07-13T18:55:25.180 回答