如何在没有页面刷新的情况下显示从asp.net日历中的下拉列表中选择的月份和年份 [英] How could I show months and year chosen from dropdownlist in asp.net calendar without page refresh
问题描述
这是我的代码,用于根据用户在下拉列表中输入的年份和月份显示年历和月份。
This is my code to show the year and month on calendar based on user entered year and month from dropdownlist.
<div>
<asp:UpdatePanel ID="updatePanelYear" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<label id="lblYears" runat="server" class="editor-label">Select Year </label>
<asp:DropDownList ID="ddlYear" runat="server" CssClass="ddlDataEntry" AppendDataBoundItems="True" AutoPostBack="True" OnSelectedIndexChanged="ddlYear_SelectedIndexChanged" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="calendar" EventName="DayRender" />
</Triggers>
</asp:UpdatePanel>
</div>
<div>
<asp:UpdatePanel ID="updatePanelMonths" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<label id="lblMonths" runat="server" class="editor-label">Select Month </label>
<asp:DropDownList ID="ddlMonth" runat="server" CssClass="ddlDataEntry" AppendDataBoundItems="True" AutoPostBack="True" OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="calendar" EventName="DayRender" />
</Triggers>
</asp:UpdatePanel>
</div>
< br $>
<asp:UpdatePanel ID="updatePanelCalender" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Calendar ID="calendar" runat="server" CssClass="myCalendarForUser" OnDayRender="calendar_DayRender">
<OtherMonthDayStyle ForeColor="#b0b0b0" />
<DayStyle CssClass="myCalendarForUserDay" ForeColor="#2d3338" />
<DayHeaderStyle CssClass="myCalendarForUserDayHeader" ForeColor="#2d3338" />
<SelectedDayStyle Font-Bold="True" Font-Size="12px" CssClass="myCalendarForUserSelector" />
<TodayDayStyle CssClass="myCalendarForUserToday" />
<SelectorStyle CssClass="myCalendarForUserSelector" />
<NextPrevStyle CssClass="myCalendarForUserNextPrev" />
<TitleStyle CssClass="myCalendarForUserTitle" />
</asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
现在,一切正常,当更新面板是不在代码中。当我在代码中放置更新面板并单击下拉列表中的月份值时,我收到一条错误消息,指出UpdatePanel'upformPanelYear'中触发器的关联控件'calendar'上的'DayRender'事件与标准事件处理程序签名不匹配。我开始知道在客户端无法解雇dayrender事件,因此发生了此错误。当用户从下拉列表中选择值时,如何更正此页面或获取页面刷新?
提前感谢。
Now, everything works fine when the update panel is not present in the code. As I placed update panel in the code and clicked on month value in dropdownlist, I got an error that says "The 'DayRender' event on associated control 'calendar' for the trigger in UpdatePanel 'updatePanelYear' does not match the standard event handler signature." i came to knew that dayrender event can not be fired on client side so this error has occured. How can i correct this or get ride of page refresh as user selects values from dropdownlist?
Thanks in advance.
推荐答案
这篇关于如何在没有页面刷新的情况下显示从asp.net日历中的下拉列表中选择的月份和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!