Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
error in aspx code
XML
<asp:Calendar ID="Calendar1" runat="server" OnDayRender="CalenderDRender" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" Width="350px" OnSelectionChanged="Calendar1_SelectionChanged">
           <SelectedDayStyle BackColor="#333399" ForeColor="White" />
           <TodayDayStyle BackColor="#CCCCCC" />
           <OtherMonthDayStyle ForeColor="#999999" />
           <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
           <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
           <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
               Font-Size="12pt" ForeColor="#333399" />
       </asp:Calendar>

error is

'ASP.default2_aspx' does not contain a definition for 'CalenderDRender'


i Also make CalenderDRender function

Default2.cs

C#
protected void CalendarDRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
    {
        // If the month is CurrentMonth
        if (!e.Day.IsOtherMonth)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))
                {
                    DateTime dtEvent = (DateTime)dr["EventDate"];
                    if (dtEvent.Equals(e.Day.Date))
                    {
                        e.Cell.BackColor = Color.PaleVioletRed;
                    }
                }
            }
        }
        //If the month is not CurrentMonth then hide the Dates
        else
        {
            e.Cell.Text = "";
        }
    }
Posted
Updated 1-May-11 7:59am
v2

1 solution

There is a typo in the name of the event method, the method is called CalendarDRender, while the control definition states CalenderDRender.

Hopes this helps.
 
Share this answer
 

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