[c#]代码库
using System;
using System.Web.UI;
namespace UpdatePanelCalendar
{
public partial class SelectCalendarDate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//获取更新控件儿
UpdatePanel mapanel = UpdatePanel1;
//设置触发模式
mapanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//添加触发
AsyncPostBackTrigger tri = new AsyncPostBackTrigger();
tri.ControlID = "ImageButton1";
tri.EventName = "Click";
mapanel.Triggers.Add(tri);
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible = false;
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (!Calendar1.Visible)
Calendar1.Visible = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
DateTime dt;
if (TextBox1.Text.Trim() != string.Empty && DateTime.TryParse(TextBox1.Text.Trim(), out dt) && Calendar1.Visible)
Calendar1.Visible = false;
}
}
}
[源代码打包下载]