Admin Admin
Mesaj Sayısı : 72 Kayıt tarihi : 02/12/08
| Konu: Dropdownlist ile seçilen değere göre Calendar ın stil değiştirmesi Cuma Ara. 05, 2008 3:33 pm | |
| Formumuza 1 adet Dropdownlist 1 Adet Calnedar ve bir adette Label ekliyoruz. 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">Dropdownlist ile seçilen değere göre Calendar ın stil değiştirmesi</font></h3>
<form id="Form1" runat="server"> Choose a Selection Mode: <asp:DropDownList id="DropDownList1" runat=server AutoPostBack=true> <asp:ListItem Value="None" >None</asp:ListItem> <asp:ListItem Value="Day" >Day</asp:ListItem> <asp:ListItem Value="DayWeek" >DayWeek</asp:ListItem> <asp:ListItem Value="DayWeekMonth" >DayWeekMonth</asp:ListItem> </asp:DropDownList>
<p>
<asp:Calendar ID="Calendar1" runat="server" onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
<p>
<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 { protected void Page_Load(object sender, EventArgs e) { Calendar1.SelectionMode = (CalendarSelectionMode)DropDownList1.SelectedIndex;
if (Calendar1.SelectionMode == CalendarSelectionMode.None) Calendar1.SelectedDates.Clear();
} protected void Calendar1_SelectionChanged(object sender, EventArgs e) { switch (Calendar1.SelectedDates.Count) { case (0): //None Label1.Text = "No dates are currently selected"; break; case (1): //Day Label1.Text = "The selected date is " + Calendar1.SelectedDate.ToShortDateString(); break; case (7): //Week Label1.Text = "The selection is a week beginning " + Calendar1.SelectedDate.ToShortDateString(); break; default: //Month Label1.Text = "The selection is a month beginning " + Calendar1.SelectedDate.ToShortDateString(); break; } } }
Formumuzu çalıştırdığımız zaman Dropdownlistten hangi değeri seçersek Calendar ın stilini değiştiğini göreceğiz.İyi Çalışmalar | |
|