2011-11-23 57 views
2

我在vb.net設置中使用fullCalendar。我使用包含一個aspx頁面內的JSON飼料將數據傳遞到像這樣的日曆:傳遞日期到JSON Feed

events: "JSONcalendarFeed.aspx" 

我在想,如果有到當前選擇的月份傳遞fullCalendar到生成JSON提要所以頁面的方式我可以提取該月的數據。同樣,每當在日曆中更改一年,我就需要在新的一年中通過。

謝謝!

回答

1

PAGE

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="diaryFeed.aspx.vb" Inherits="ClubSites.diaryFeed" %> 
<% Response.Write(respondBack)%> 

後面的代碼

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

If Request.QueryString.ToString <> "" Then 
      'I don't understand why fullCalendar uses a Unix timestamp.. but use these queries if you use UNIX timestamp, common in PHP apparently 

      If IsNothing(Request.QueryString("start")) Then 
       _startDate = Date.Now.AddYears(-1) 
       _endDate = Date.Now.AddYears(1) 
      Else 
       _startDate = CDateFromUNIX(Request.QueryString("start")) 
       _endDate = CDateFromUNIX(Request.QueryString("end")) 

      End If 
      Try 
       If Not Request.QueryString("Timestart").Length = 0 And Not Request.QueryString("TimeEnd").Length = 0 Then 
        _startDate = CDate(Request.QueryString("Timestart")) 
        _endDate = CDate(Request.QueryString("TimeEnd")) 
       End If 
      Catch ex As Exception 

      End Try 
      'End If 

respondBack = JsonConvert.SerializeObject([mycustom function that generates a data table], New Newtonsoft.Json.Converters.IsoDateTimeConverter()) 


end sub 

我使用JSON .NET我的輸出數據轉換成JSON,這樣的日記可以把它理解

和一個輔助函數到Unix時間戳轉換到.NET一個

Function CDateFromUNIX(ByVal timestamp As Double) As DateTime 
     Dim origin As DateTime = New DateTime(1970, 1, 1, 0, 0, 0, 0) 
     Return origin.AddSeconds(timestamp) 
    End Function 
+0

這不需要每次用戶去前/後一個月,一週或一天的回傳? – SkyeBoniwell

+0

我使用Ajax請求..(回傳是如此1990)但通常是 - 如果您不需要實時更新數據,然後使用fullCalendars內部緩存功能。但是你可以關閉它,所以它總是要求數據。 – ppumkin

2

我非常確定fullCalendar實際上會將開始和結束時間作爲參數發送到您的頁面。

從的例子說:/myfeed.php?start=1262332800 &末= 1265011200 所以你應該只是讀這兩個參數,並從秒將它們轉換(在fullCalendar不是MS!)自1970年1月1日

+0

確實日曆自動拾取開始並結束日期,如果他們在那裏? - 感謝 – SkyeBoniwell

+0

這是真正的fullcalendar v1。從V2開始,它在任何地方都使用utf日期和時間。順便說一句,我正在尋找如何回到unix系統時間 – netalex