Admin Admin
Mesaj Sayısı : 72 Kayıt tarihi : 02/12/08
| Konu: Calendar da seçilen tarihin renginin değişmesi Cuma Ara. 05, 2008 4:07 pm | |
| Default.aspx - Kod:
-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <h3><font face="Verdana">Calendar da seçilen tarihin renginin değişmesi</font></h3>
<form id="Form1" runat="server">
<asp:Calendar id="Calendar1" runat="server" ondayrender="Calendar1_DayRender" onselectionchanged="Date_Selected" ShowGridLines="true" Font-Names="Verdana;Arial" Font-Size="9px" Width="500px" VisibleDate="01/01/2000" TitleStyle-BackColor="Gainsboro" TitleStyle-Font-Size="12px" TitleStyle-Font-Bold="true" DayStyle-VerticalAlign="Top" DayStyle-Height="50px" DayStyle-Width="14%" SelectedDate="1/1/0001" SelectedDayStyle-BackColor="Navy" />
<asp:Label id="Label1" runat="server" /> </form>
</body> </html>
Default.aspx.cs - Kod:
-
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page { String[][] holidays;
protected void Page_Load(object sender, EventArgs e) { holidays = new String[13][];
for (int n = 0; n < 13; n++) holidays[n] = new String[32];
holidays[1][1] = "New Year's Day"; holidays[1][26] = "Australia Day"; holidays[2][2] = "Groundhog Day"; holidays[2][14] = "Valentine's Day"; holidays[3][17] = "St. Patrick's Day"; holidays[4][1] = "April Fool's Day"; holidays[5][1] = "May Day"; holidays[6][15] = "My Birthday"; holidays[7][15] = "My Anniversary"; holidays[8][15] = "My Mother's Birthday"; holidays[9][24] = "Autumnal Equinox"; holidays[12][26] = "Boxing Day";
}
protected void Date_Selected(object sender, EventArgs e) { Label1.Text = "Selected date is: " + Calendar1.SelectedDate.ToShortDateString(); }
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { CalendarDay d = ((DayRenderEventArgs)e).Day; TableCell c = ((DayRenderEventArgs)e).Cell;
if (d.IsOtherMonth) { c.Controls.Clear(); } else { try { string Hol = holidays[d.Date.Month][d.Date.Day];
if (Hol != string.Empty) c.Controls.Add(new LiteralControl("<br>" + Hol)); } catch (Exception exc) { Response.Write(exc.ToString()); } } } }
| |
|