Du kan få noget her ... Ikke ligefrem produktionskode, men du kan da lige se om det kunne være en model:
En kalenderkontrol:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CalendarStuff.ascx.cs" Inherits="UserControls_CalendarStuff" %>
<%@ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>
<div>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="conditional">
<ContentTemplate>
<center>
<asp:TextBox ID="DateTextBox" runat="server" Width="165px"></asp:TextBox>
<asp:Panel ID="pnlPopUp" runat="server" CssClass="popupControl">
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged">
</asp:Calendar>
</asp:Panel>
</center>
</ContentTemplate>
</atlas:UpdatePanel>
<atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server">
<atlasToolkit:PopupControlProperties TargetControlID="DateTextBox" PopupControlID="pnlPopUp" Position="Bottom" />
</atlasToolkit:PopupControlExtender>
</div>
Og koden til den:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AtlasControlToolkit;
using Microsoft.Web.UI;
public partial class UserControls_CalendarStuff : System.Web.UI.UserControl
{
public event EventHandler DateChanged;
protected virtual void OnDateChanged()
{
if (DateChanged != null)
{
DateChanged(this, EventArgs.Empty);
}
}
public DateTime SelectedDate
{
get
{
return (object)ViewState["SelectedDate"] != null ? (DateTime)ViewState["SelectedDate"] : DateTime.MinValue;
}
protected set
{
ViewState["SelectedDate"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
PopupControlExtender.GetCurrent(this.Page).Commit(Calendar1.SelectedDate.ToShortDateString());
SelectedDate = Calendar1.SelectedDate;
OnDateChanged();
}
public void ClearDate()
{
this.DateTextBox.Text = String.Empty;
this.UpdatePanel1.Update();
}
}
Og en side:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CalendarPage.aspx.cs" Inherits="CalendarPage" %>
<%@ Register Src="UserControls/CalendarStuff.ascx" TagName="CalendarStuff" TagPrefix="uc1" %>
<!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>
<form id="form1" runat="server">
<atlas:ScriptManager ID="sm" runat="server" EnablePartialRendering="true"></atlas:ScriptManager>
<br />
<uc1:CalendarStuff ID="CalendarStuff1" runat="server" OnDateChanged="cal_DateChanged" />
<br />
<br />
<uc1:CalendarStuff ID="CalendarStuff2" runat="server" OnDateChanged="cal_DateChanged" />
<br />
<br />
<uc1:CalendarStuff id="CalendarStuff3" runat="server">
</uc1:CalendarStuff>
</form>
</body>
</html>
Og koden til den:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CalendarPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void cal_DateChanged(object sender, EventArgs e)
{
if (sender == CalendarStuff1)
{
DateTime selectedDate1 = CalendarStuff1.SelectedDate;
DateTime selectedDate2 = CalendarStuff2.SelectedDate;
if (selectedDate1 < selectedDate2)
{
CalendarStuff2.ClearDate();
CalendarStuff2.ClearDate();
}
}
}
}
Det er ikke fordi den gør nøjagtig det du har bedt om - men klodserne til det skulle være der.... Så må du selv fikse logikken op.
Mvh