views:

59

answers:

2

hi all

I have tried some code for fetching events from C# application to my fullcalendar plugin interface. The code is posted below.

Code explanation: DefaultAdmin is the main page where calendar is located. It calls eventsList.aspx to fetch events data in json format. A value object called CalendarDTO.cs is also used.

Problem: When i run this code, I get the events on my calendar but they remain uneditable. I am not able to drag them.

-------------------------DefaultAdmin.aspx.cs--------------------------

public partial class DefaultAdmin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

--------------------------DefaultAdmin.aspx--------------------------

<%@ Page Title="" Language="C#" MasterPageFile="~/HomeMasterPage.master" AutoEventWireup="true" 

CodeFile="DefaultAdmin.aspx.cs" Inherits="DefaultAdmin" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script src="fullcalendar-1.4.7/jquery/jquery.js" type="text/javascript"></script>
    <link href="fullcalendar-1.4.7/fullcalendar.css" rel="stylesheet" type="text/css" />
    <script src="fullcalendar-1.4.7/fullcalendar.min.js" type="text/javascript"></script>       
<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({
            theme: true,
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            defaultView: 'agendaMonth',
            selectable: true,
            selectHelper: true,
            editable: true,
            events: "eventsList.aspx"

        });
    });

</script>

<div id='calendar'></div> 

</asp:Content>

-------------------------eventsList.aspx--------------------------

<%@ Page Title="" Language="C#" MasterPageFile="~/HomeMasterPage.master" AutoEventWireup="true" CodeFile="eventsList.aspx.cs" Inherits="eventsList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">   
</asp:Content>

--------------------------eventsList.aspx.cs---------------------

public partial class eventsList: System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
  string startDate = ToUnixTimespan(System.DateTime.Now).ToString();
        string endDate = ToUnixTimespan(DateTime.Now.AddDays(1)).ToString();

        List<CalendarDTO> events = new List<CalendarDTO>();

        DateTime starting = FromUnixTimespan(startDate);
        for (int i = 0; i <= 4; i++)
        {
            CalendarDTO value = new CalendarDTO();
            value.start = ToUnixTimespan(starting.AddDays(i * 2));
            value.id = i;
            value.title = "Title of event number " + i.ToString();
            value.editable = true;

            if (i % 2 == 1)
            {
                value.end = ToUnixTimespan(starting.AddDays(1 + (i * 3)));
            }
            events.Add(value);
        }
        System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
        Response.Clear();
        Response.Write(js.Serialize(events));
        Response.End();
    }

    private Int64 ToUnixTimespan(DateTime d)
    {
        TimeSpan time = new TimeSpan();
        time = d.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0));

        return (Int64)Math.Truncate(time.TotalSeconds);
    }

    private DateTime FromUnixTimespan(string s)
    {
        DateTime time = new DateTime(1970, 1, 1, 0, 0, 0);
        return time.AddSeconds (Int32.Parse(s));
    }

}

----------------------------CalendarDTO.cs--------------------------------

public class CalendarDTO
{
    private Int32 m_id;
    public Int32 id
    {
        get { return m_id; }
        set { m_id = value; }
    }

    private string m_Title;
    public string title
    {
        get { return m_Title; }
        set { m_Title = value; }
    }

    private Int64 m_Start;
    public Int64 start
    {
        get { return m_Start; }
        set { m_Start = value; }
    }

    private Int64 m_End;
    public Int64 end
    {
        get { return m_End; }
        set { m_End = value; }
    }

    private bool m_Editable;
    public bool editable
    {
        get { return m_Editable; }
        set { m_Editable = value; }
    }
    private string m_Url;
    public string url
    {
        get { return m_Url; }
        set { m_Url = value; }
    }
}
A: 

I would really appreciate if someone can tryout this code and help me. The above code is using a masterpage that I missed in my last query. I am uploading the whole project that you can just download and run.

The code is located at : http://uploading.com/files/aaf23cmd/FinalDemo.zip/

A: 

If this is still relevant , take a look at: http://arshaw.com/fullcalendar/docs/event_ui/Requirements/

looks like you are missing a few js file links.

gsapir