首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

两个calendar控件联动?该如何处理

2012-01-09 
两个calendar控件联动???两个calendar控件,怎么能让他俩联动呢???就是我点击其中一个的上一月下一月按钮,

两个calendar控件联动???
两个calendar控件,怎么能让他俩联动呢???

就是我点击其中一个的上一月下一月按钮,这俩个是同时改变。。。

[解决办法]
Sample


<%@ Page Language= "C# " %>

<%--http://community.csdn.net/Expert/TopicView3.asp?id=5656525--%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script runat= "server ">

protected void Page_Load(object sender, EventArgs e)
{

}

protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
Calendar calendar = sender as Calendar;
if (calendar == Calendar1) {
Calendar2.VisibleDate = e.NewDate;
}
else {
Calendar1.VisibleDate = e.NewDate;
}
}
</script>

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Calendar ID= "Calendar1 " runat= "server " OnVisibleMonthChanged= "Calendar1_VisibleMonthChanged "> </asp:Calendar>
<asp:Calendar ID= "Calendar2 " runat= "server " OnVisibleMonthChanged= "Calendar1_VisibleMonthChanged "> </asp:Calendar>
</div>
</form>
</body>
</html>

热点排行