0
votes
<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 image database

I want to insert data(database) in events: [(javascript).My idea was to use linq foreach but will send it to the javascript tag event and I've heard that using json, but do not know how to use it because it uses is not.

I was Thailand. Not proficient in English. I thank everyone very much.

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
             //  }
        }
1

1 Answers

1
votes

Try using the 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);