我有一个带有日历的 ac# web 应用程序 - 没什么特别的。我遇到的问题是只能点击数字而不是整个单元格。我添加了一个 onmouseover 类型的处理程序,它使单元格在鼠标悬停时改变颜色,但这会产生误导,因为您不能单击边缘。
在asp.net c#中有什么方法可以让这个日历允许整个单元格可以点击,而不仅仅是日期的超文本编号?我希望我已经解释得足够好。
谢谢
<asp:Calendar ID="Calendar1" runat="server"
DayStyle-ForeColor="DarkBlue"
DayHeaderStyle-BackColor="#FEF6CB"
DayStyle-Height="25"
SelectedDayStyle-BackColor="#003F7D"
SelectedDayStyle-ForeColor="White"
DayNameFormat="FirstLetter"
ShowGridLines="true"
BorderColor="Black"
TitleStyle-BackColor="#003F7D"
TitleStyle-ForeColor="White"
TitleStyle-CssClass="CalHeader"
NextPrevStyle-CssClass="CalNextPrev"
NextPrevStyle-ForeColor="White"
OnVisibleMonthChanged="cal_ReserveDate_VisibleMonthChanged"
OnDayRender="cal_ReserveDate_DayRender"
OnSelectionChanged="cal_ReserveDate_SelectionChanged"
DayStyle-BorderColor="Black"
SelectedDayStyle-CssClass="CalendarSelectedDay"
Width="97%" />
更新:
这是 ascx 页面的基本框架:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BuyTourProductDialogGalaxy2.ascx.cs" Inherits="ConLib_Custom_BuyTourProductDialog2" %>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function fixCalendar() {
var a = $('#<%=cal_ReserveDate.ClientID%> a ');
a.contents().wrap("<div/>");
}
</script>
<asp:UpdatePanel ID="upnl_Cal" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<div class="BuyTourProductDialog">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td colspan="2" width="75%">
<asp:Label ID="lblInstructions" runat="server" Text="" EnableViewState="False" CssClass="ReservationInstructions" />
</td>
<td width="25%">
<span style="float: right;">
<asp:Button ID="btn_Reset" runat="server" Text="Reset" OnClick="btn_Reset_Click" Visible="false" CssClass="ResetButton" />
<asp:Button ID="btn_Reserve" runat="server" Text="Reserve" OnClick="btn_Reserve_Click" Visible="true" />
<asp:Button ID="btn_AddToCart" runat="server" Text="Add To Cart" Visible="false" OnClick="btn_AddToCart_Click" />
<asp:Button ID="btn_Continue" runat="server" Text="Continue" Visible="false" OnClick="btn_Continue_Click" />
</span>
</td>
</tr>
</table>
<%-- Calendar Panel --%>
<asp:Panel ID="pnl_GatewayCalendar" runat="server" Visible="false">
<table width="100%">
<%-- Header --%>
<tr>
<td align="center" colspan="2">
<asp:Label ID="lbl_SelectedDate" runat="server" Font-Bold="true" CssClass="SelectedDate" /><br />
</td>
</tr>
<tr>
<%-- Calendar side --%>
<td width="50%" valign="top">
<asp:Calendar ID="cal_ReserveDate" runat="server"
DayStyle-ForeColor="DarkBlue" DayHeaderStyle-BackColor="#FEF6CB" DayStyle-Height="25"
SelectedDayStyle-BackColor="#003F7D" SelectedDayStyle-ForeColor="White"
DayNameFormat="FirstLetter" ShowGridLines="true" BorderColor="Black"
TitleStyle-BackColor="#003F7D" TitleStyle-ForeColor="White" TitleStyle-CssClass="CalHeader"
NextPrevStyle-CssClass="CalNextPrev" NextPrevStyle-ForeColor="White"
OnVisibleMonthChanged="cal_ReserveDate_VisibleMonthChanged"
OnDayRender="cal_ReserveDate_DayRender" OnSelectionChanged="cal_ReserveDate_SelectionChanged"
DayStyle-BorderColor="Black" SelectedDayStyle-CssClass="CalendarSelectedDay" Width="97%" />
</td>
<%-- Event Times side --%>
<td valign="top">
<%-- Another section here for tour times. --%>
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>