Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is my code to show the year and month on calendar based on user entered year and month from dropdownlist.

XML
<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>




XML
<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>



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.
Posted
Comments
SRS(The Coder) 25-Jun-14 6:44am    
Why don't you set the ClientIDMode to 'Static' for those controls and set the selected month and year using jQuery it will be easier and clear in implementation rather than using UpdatePanel ?
Codes DeCodes 25-Jun-14 7:07am    
As i am new to this, i do not know much about it.. Can you provide me link of this!!
Vi(ky 25-Jun-14 7:19am    
See here
http://jqueryui.com/datepicker/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900