我在做一个查询页面需要选择 起始日期 和 截止日期 我想用 Calendar控件做。 我想在页面加载时,用下拉框形式显示。两个DropDownList(1 开始日期、2 截止日期)都显示的当天的日期。一点DropDownList就弹出Calendar点选其中一天后,Calendar消失 DropDownList显示的我点选的那个日期。现在不会做的是
1、DropDownList怎么显示当天日期?
2、DropDownList怎么获取Calendar选中的日期?
3、如何讲DropDownList获得的日期赋给变量?

解决方案 »

  1.   

    b/s   or  c/s
      

  2.   

    哦 那么点击TextBox的事件怎么写呢?
      

  3.   

    看看这个例子
    http://www.cnblogs.com/sysuhekaifeng/archive/2009/01/22/1380093.html
      

  4.   

    如果是web的,你可以直接用个js的日历控件,方便好用。如果是win的,你可以上网找找有没有现成的第三方控件
      

  5.   

    ASP.NET带日历控件呀,为什么要用JS呢...
      

  6.   

    是的,b/s中一般是这样做的,c/s中一般用DateTimePicker控件
      

  7.   


    我们只用My97 js日历控件My97使用方便  功能强大   浏览器兼容性好  
    用了多说好   大家好才是真的好   哈哈
      

  8.   

    my97 JS日历http://www.my97.net/dp/demo/index.htm
      

  9.   

    前台:
    <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;
    }