我一直在這個網站上VS 2012 for Web 2012的工作。它大部分是HTML和ASP,但我已經包含從SourceForge下載的DayPilot日曆。顯然,我必須將日曆數據綁定到我的SQL服務器,以便用戶可以在日曆上登錄併爲自己留出時間。我已經使用了幾乎所有可以在網上找到的推薦代碼,但在日曆頁面上似乎沒有任何工作。 這裏是aspx頁面和頁面aspx.vb代碼: (aspx頁面)ASP.net網站DataBind到SQL服務器
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="calendarpg.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript" src="<%=ResolveUrl("~/Scripts/DayPilot/calendar.js")%>">
</script>
<style type="text/css">
.auto-style8 {
font-size: large;
}
</style>
<link type="text/css" rel="stylesheet" href="<%=ResolveUrl("~/Themes/themes.css")%>" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
dbo.BasicData
<DayPilot:DayPilotNavigator ID="DayPilotNavigator1" runat="server" />
<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" Days="7" EventMoveJavaScript="alert('eventMove(e.start(), newEnd')" BackColor="#CCFFFF" DataStartField="null"></DayPilot:DayPilotCalendar>
<DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server">
</DayPilot:DayPilotScheduler>
<br />
<h1><strong>Scheduling</strong></h1>
<span class="auto-style8">Requests are made via the Calendar for each of the respective Sandboxes.
A minimum of 24-hour notice is rquired when making a request to allow
time for preparation of a Sandbox,
<br />
time zone differences, and to resolve any
scheduling conflicts.
<br />
<br />
The process for booking is similar to booking a conference room.
<br />
<br />
Choose a day and time that is open, for the Sandbox you're interested in using,
then choose the open hours that work best for your schedule. </span>
</asp:Content>
(aspx.vb頁)
Partial Class _Default
Inherits System.Web.UI.Page
'Declaration
Public Event DataBinding As EventHandler
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DayPilotCalendar1.DataSource = getData()
DataBind()
End Sub
Public Function getData() As Data.DataTable
Dim dt As Data.DataTable
dt = New Data.DataTable
dt.Columns.Add("start", GetType(DateTime))
dt.Columns.Add("end", GetType(DateTime))
dt.Columns.Add("name", GetType(String))
dt.Columns.Add("id", GetType(String))
Dim dr As Data.DataRow = dt.NewRow()
dr("id") = 0
dr("start") = Convert.ToDateTime("15:50")
dr("end") = Convert.ToDateTime("15:55")
dr("name") = "Event 1"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("id") = 1
dr("start") = Convert.ToDateTime("16:00")
dr("end") = Convert.ToDateTime("17:00")
dr("name") = "Event 2"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("id") = 2
dr("start") = Convert.ToDateTime("16:15")
dr("end") = Convert.ToDateTime("18:45")
dr("name") = "Event 3"
dt.Rows.Add(dr)
Return dt
End Function
End Class
(這是我的web.config頁面,因爲它代表現在)
<using System.Web.Configuration; />
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ConnStringDb1" connectionString="DataSource=Win08-SDBX1\SQLExpress;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5">
<assemblies>
<add assembly="Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.VisualStudio.Tools.Applications.Adapter.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.VisualStudio.Tools.Applications.Hosting.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.VisualStudio.Tools.Applications.ProgrammingModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<pages>
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
</system.web>
</configuration>
如果有任何意義,或者你看到我要去哪裏出錯,請分享或更正我的編碼。謝謝!
我看到的第一件事,時間設置爲24H格式...可能是一個問題 – SerenityNow
我應該添加,當我在測試服務器上運行網站時,日曆的aspx.vb頁面出現問題DataBind()控制代碼。我不斷收到消息: 「NullReferenceException未被用戶代碼處理」 –
如果您不將日曆控件綁定到任何內容,它是否顯示在測試服務器上? – SerenityNow