Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
157 Points
524 Posts
Mar 30, 2012 08:11 AM|LINK
cninjas hi I am pasting the working sample here.hope it helps.. <div> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" ondayrender="calDT_DayRender" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="502px" NextPrevFormat="FullMonth" Width="716px"> <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> </div> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> <asp:LinkButton ID="CalendarLinkButton" Visible=false runat="server" CssClass="hide" OnClick="CalendarLinkButton_Click"></asp:LinkButton> List<DateTime> dtholidays = null; protected void Page_Load(object sender, EventArgs e) { dtholidays = GetPublicHolidays(); } protected void calDT_DayRender(object sender, DayRenderEventArgs e) { if (dtholidays.Contains(e.Day.Date)) { e.Cell.Controls.Add(new LiteralControl("<br /><font color=red>Holiday</font>")); HyperLink link = new HyperLink(); link.CssClass = "activity"; link.ImageUrl = "del.png"; link.ToolTip = e.Day.Date.ToString(); link.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton,e.Day.Date.ToString(), true); e.Cell.Controls.Add(link); } } public void onCalendarImageClick(object sender, ImageClickEventArgs e) { } private List<DateTime> GetPublicHolidays() { List<DateTime> list = new List<DateTime>(); //populate from database or other sources list.Add(new DateTime(2012, 01, 01)); list.Add(new DateTime(2012, 02, 02)); list.Add(new DateTime(2012, 02, 14)); list.Add(new DateTime(2012, 03, 02)); list.Add(new DateTime(2012, 03, 14)); list.Add(new DateTime(2012, 04, 02)); list.Add(new DateTime(2012, 04, 14)); list.Add(new DateTime(2012, 05, 02)); list.Add(new DateTime(2012, 05, 14)); list.Add(new DateTime(2012, 06, 02)); list.Add(new DateTime(2012, 06, 14)); list.Add(new DateTime(2012, 07, 02)); list.Add(new DateTime(2012, 07, 14)); list.Add(new DateTime(2012, 08, 02)); list.Add(new DateTime(2012, 08, 14)); list.Add(new DateTime(2012, 09, 02)); list.Add(new DateTime(2012, 09, 14)); list.Add(new DateTime(2012, 10, 02)); list.Add(new DateTime(2012, 10, 14)); list.Add(new DateTime(2012, 11, 02)); list.Add(new DateTime(2012, 11, 14)); list.Add(new DateTime(2012, 12, 02)); list.Add(new DateTime(2012, 12, 14)); return list; } protected void CalendarLinkButton_Click(object sender, EventArgs e) { Response.Write(Request.Form["__EVENTARGUMENT"]); }
hi
I am pasting the working sample here.hope it helps..
<div> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" ondayrender="calDT_DayRender" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="502px" NextPrevFormat="FullMonth" Width="716px"> <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> </div> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> <asp:LinkButton ID="CalendarLinkButton" Visible=false runat="server" CssClass="hide" OnClick="CalendarLinkButton_Click"></asp:LinkButton>
List<DateTime> dtholidays = null; protected void Page_Load(object sender, EventArgs e) { dtholidays = GetPublicHolidays(); } protected void calDT_DayRender(object sender, DayRenderEventArgs e) { if (dtholidays.Contains(e.Day.Date)) { e.Cell.Controls.Add(new LiteralControl("<br /><font color=red>Holiday</font>")); HyperLink link = new HyperLink(); link.CssClass = "activity"; link.ImageUrl = "del.png"; link.ToolTip = e.Day.Date.ToString(); link.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton,e.Day.Date.ToString(), true); e.Cell.Controls.Add(link); } } public void onCalendarImageClick(object sender, ImageClickEventArgs e) { } private List<DateTime> GetPublicHolidays() { List<DateTime> list = new List<DateTime>(); //populate from database or other sources list.Add(new DateTime(2012, 01, 01)); list.Add(new DateTime(2012, 02, 02)); list.Add(new DateTime(2012, 02, 14)); list.Add(new DateTime(2012, 03, 02)); list.Add(new DateTime(2012, 03, 14)); list.Add(new DateTime(2012, 04, 02)); list.Add(new DateTime(2012, 04, 14)); list.Add(new DateTime(2012, 05, 02)); list.Add(new DateTime(2012, 05, 14)); list.Add(new DateTime(2012, 06, 02)); list.Add(new DateTime(2012, 06, 14)); list.Add(new DateTime(2012, 07, 02)); list.Add(new DateTime(2012, 07, 14)); list.Add(new DateTime(2012, 08, 02)); list.Add(new DateTime(2012, 08, 14)); list.Add(new DateTime(2012, 09, 02)); list.Add(new DateTime(2012, 09, 14)); list.Add(new DateTime(2012, 10, 02)); list.Add(new DateTime(2012, 10, 14)); list.Add(new DateTime(2012, 11, 02)); list.Add(new DateTime(2012, 11, 14)); list.Add(new DateTime(2012, 12, 02)); list.Add(new DateTime(2012, 12, 14)); return list; } protected void CalendarLinkButton_Click(object sender, EventArgs e) { Response.Write(Request.Form["__EVENTARGUMENT"]); }
I've already tried this code, and its not working. List<DateTime> doesnot get recognised.
Can you help me with doing so via stored procedures..?
coolpal9
Member
157 Points
524 Posts
Re: calendar control: how to remove holidays and update it in the database
Mar 30, 2012 08:11 AM|LINK
I've already tried this code, and its not working. List<DateTime> doesnot get recognised.
Can you help me with doing so via stored procedures..?