我在做一个查询页面需要选择 起始日期 和 截止日期 我想用 Calendar控件做。 我想在页面加载时,用下拉框形式显示。两个DropDownList(1 开始日期、2 截止日期)都显示的当天的日期。一点DropDownList就弹出Calendar点选其中一天后,Calendar消失 DropDownList显示的我点选的那个日期。现在不会做的是
1、DropDownList怎么显示当天日期?
2、DropDownList怎么获取Calendar选中的日期?
3、如何讲DropDownList获得的日期赋给变量?
1、DropDownList怎么显示当天日期?
2、DropDownList怎么获取Calendar选中的日期?
3、如何讲DropDownList获得的日期赋给变量?
http://www.cnblogs.com/sysuhekaifeng/archive/2009/01/22/1380093.html
我们只用My97 js日历控件My97使用方便 功能强大 浏览器兼容性好
用了多说好 大家好才是真的好 哈哈
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>请选择起始日期...</asp:ListItem>
<asp:ListItem>起始日期</asp:ListItem>
</asp:DropDownList>
<asp:Calendar ID="Calendar1" runat="server"
onselectionchanged="Calendar1_SelectionChanged" Visible="False">
<SelectedDayStyle BackColor="#FF66CC" />
</asp:Calendar>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
<asp:ListItem>请选择结束日期...</asp:ListItem>
<asp:ListItem>结束日期</asp:ListItem>
</asp:DropDownList>
<asp:Calendar ID="Calendar2" runat="server"
onselectionchanged="Calendar2_SelectionChanged" Visible="False">
<SelectedDayStyle BackColor="#3333FF" />
</asp:Calendar>
后台:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
DropDownList1.Items.Add(Calendar1.SelectedDate.ToString("yyyy-MM-dd"));
DropDownList1.Text = DropDownList1.Items[DropDownList1.Items.Count-1].Text;
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
Calendar2.Visible = true;
}
protected void Calendar2_SelectionChanged(object sender, EventArgs e)
{
DropDownList2.Items.Add(Calendar2.SelectedDate.ToString("yyyy-MM-dd"));
DropDownList2.Text = DropDownList2.Items[DropDownList2.Items.Count-1].Text;
}