0

我有一个 asp 日历控件,它包含在更新面板中。单击日期时,不会触发 SelectionChanged() 事件。这是代码。

ASPX -

<asp:Calendar ID="Calendar" runat="server" BorderColor="green" NextPrevStyle-BackColor="green"
BorderStyle="Solid" Height="414px" NextPrevFormat="FullMonth" TitleStyle-BackColor="green"
DayStyle-Font-Underline="false" ShowGridLines="True" Width="567px" onvisiblemonthchanged="Calendar_VisibleMonthChanged"
SelectedDate="02/23/2013 15:33:22" VisibleDate="2013-02-23" onselectionchanged="Calendar_SelectionChanged">
    <DayStyle Font-Underline="True" />
    <NextPrevStyle BackColor="green" />
    <SelectedDayStyle BackColor="green" Font-Bold="True" ForeColor="Black"
    />
    <SelectorStyle Font-Bold="True" />
    <TitleStyle BackColor="green" Font-Underline="False" />
    <TodayDayStyle BackColor="green" Font-Bold="True" ForeColor="White" />
</asp:Calendar>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Calendar" EventName="SelectionChanged"
        />
    </Triggers>
</asp:UpdatePanel>

服务器端代码 -

protected void Calendar_SelectionChanged(object sender, EventArgs e)
        {
            Label1.Text = CalEdairy.SelectedDate.ToShortDateString();
        }
4

1 回答 1

0

我尝试了上面的代码,它对我来说工作正常。(除了我删除了 onvisiblemonthchanged="Calendar_VisibleMonthChanged")

于 2013-02-24T04:02:29.007 回答