Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is my aspx:

ASP.NET
<asp:Calendar ID="Calendar1"  BackColor="White"
       BorderColor="Black" Font-Names="Verdana"
       Font-Size="9pt" ForeColor="Black" Height="450px" NextPrevFormat="ShortMonth"
       Width="1000px" ondayrender="Calendar1_DayRender" runat="server"  BorderStyle="Solid"
       CellSpacing="1" ToolTip="Event Calendar"   >
       <DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
           Height="8pt" />
       <DayStyle BackColor="#CCCCCC" />
       <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />
       <OtherMonthDayStyle ForeColor="#999999" />
       <SelectedDayStyle BackColor="#333399" ForeColor="White" />
       <TitleStyle BackColor="#5D7B9D" Font-Bold="True"
           Font-Size="12pt" ForeColor="White" BorderStyle="Solid" Height="12pt" />
       <TodayDayStyle BackColor="#999999" ForeColor="White" />
   </asp:Calendar>


and in my c#

C#
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
        {
            try
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    DateTime dt = (DateTime)dr.Field<DateTime?>("open_date");
                    if (e.Day.Date == dt.Date)
                    {
                        e.Cell.BackColor = System.Drawing.Color.LightSkyBlue;
                        Literal ltr = new Literal();
                        string br = "<br/>";
                        ltr.Text = br + dr[0].ToString();
                        e.Cell.Controls.Add(ltr);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }


but compiler Error Message show : 'contact_aspx' does not contain a definition for 'Calendar1_DayRender' and no extension method 'Calendar1_DayRender' accepting a first argument of type 'contact_aspx' could be found (are you missing a using directive or an assembly reference?),why?

What I have tried:

added runat="server" in my aspx,but still not working.
Posted
Comments
Karthik_Mahalingam 16-Jun-16 23:57pm    
post your complete aspx and aspx.cs code..
Vincent Maverick Durano 20-Jun-16 10:24am    
Your code looks good to me. Try creating a new webform, grab a new calendar control and generate the DayRender event just to see if it recognizes the event. I know it's not an ideal solution, but sometimes VStudio is crazy. ;)

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