-2
我使用渲染選項創建了一個日曆。它在我的本地機器上完美工作,但它不能在服務器上工作。我在一臺日曆上顯示員工時間表,在本地機器上工作正常。但現在我發佈在服務器上,它不在那裏工作。日曆日不適用於服務器端
我的部分代碼是在這裏:
if (e.Day.Date.Month == DateTime.Now.Month - 1)
{
if ((lblfromdate.Text != "") && (lbltodate.Text != ""))
{
if (e.Day.Date < Convert.ToDateTime(lblfromdate.Text))
{
e.Cell.Text = string.Empty;
e.Cell.BorderColor = System.Drawing.Color.White;
}
else
{
DataSet4TableAdapters.sp_getallholidayinfoTableAdapter TA = new DataSet4TableAdapters.sp_getallholidayinfoTableAdapter();
DataSet4.sp_getallholidayinfoDataTable DS = TA.GetData();
if (DS.Rows.Count > 0)
{
DataView DV = new DataView();
DV = DS.DefaultView;
string fromdate = Convert.ToString(lblfromdate.Text.Substring(5, 2) + "-" + lblfromdate.Text.Substring(8, 2) + "-" + lblfromdate.Text.Substring(0, 4));
string todate = Convert.ToString(lbltodate.Text.Substring(5, 2) + "-" + lbltodate.Text.Substring(8, 2) + "-" + lbltodate.Text.Substring(0, 4));
DV.RowFilter = "fldfromdate >=#" + fromdate + "# and fldfromdate <=#" + todate + "#";
if (DV.Count > 0)
{
string indate = Convert.ToString(DV[0]["fldfromdate"]);
string input = indate.Substring(6) + "-" + indate.Substring(0, 2) + "-" + indate.Substring(3, 2);
if (Convert.ToString(e.Day.Date.ToShortDateString()) == input)
{
e.Cell.Controls.Clear();
e.Cell.Text = "Holiday";
e.Cell.BackColor = System.Drawing.Color.BlueViolet;
}
}
}
}
}
}
我的設計代碼:
<asp:Calendar ID="Calendar2" runat="server" BackColor="White"
BorderColor="Black" BorderWidth="2px" Enabled="False"
Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
Height="183px" NextPrevFormat="FullMonth" ShowGridLines="True"
Width="659px" OnDayRender="Calendar2_DayRender" ShowNextPrevMonth="False">
<DayHeaderStyle BackColor="#6699FF" BorderStyle="Solid"
Font-Bold="True" Font-Size="8pt" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt"
ForeColor="#333333" VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle ForeColor="White" />
<TitleStyle BackColor="White" BorderColor="Black" BorderStyle="None"
Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
」它不在那裏工作「作爲描述是相當無用的。究竟發生了什麼/沒有發生?錯誤消息,內容只是沒有呈現,只是錯誤的格式? – 2012-04-25 09:22:42
我只發佈我的部分代碼。我的代碼中有超過2000行.. – Fernando 2012-04-25 09:24:52
請告訴我們什麼「不工作」。您是否收到服務器端錯誤(500)?日期/日期範圍不是您所期望的嗎?你不需要2000 LOC來顯示日曆。看起來你想把假期變成彩色,而這些日子是從數據庫中讀取的。您是否已經檢查過從數據庫中讀取的數據是否正確/如您所期望的那樣? – Filburt 2012-04-25 09:37:18