从日历显示到DropDownList中 [英] Displayed into DropDownList from calender

查看:92
本文介绍了从日历显示到DropDownList中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生您好,
我正在C#中使用Asp.net,到目前为止,我已经在Asp.net表单窗口中显示了dropdownList和该日历旁边的日历.我需要的是日历应该不显示在浏览器中,因为我执行了.当我单击DropDownList日历必须显示在DropDownList旁边,并且当我从日历中选择日期和月份时,它必须< b>显示在DropDownList</b>中.如何实现此提示...
如果尽早播放,这将是最有帮助的..


谢谢你,
Pradeep cb

Hello sir,
I am using Asp.net with C#, has of now i had displayed dropdownList and next to that calender in Asp.net Form window.What i need is the calender should not be displayed in the browser,as i executed.When i click the DropDownList the calender has to be displayed next to DropDownList and when i select the date and month from calender it has to <b>displayed in the DropDownList</b>.How to achieve this sir...
It will be most helpfull,if replayed as early..


Thanking u,
Pradeep cb

推荐答案

朋友,

1.使日历的可见属性为假
2.并且当下拉列表中的selectedIndexChanged()事件触发时,使日历可见.
3.然后设置dropdownlist.text = calender.text
Hi friends,

1. make visible property of calender false
2. And when the selectedIndexChanged() event of drop down list fires make calender visible.
3. then set dropdownlist.text=calender.text


尝试一下

Try This

<form name="form1" id="fom1" action=""  runat="server">		
		    <asp:image id="Image1" runat="server" height="195px" width="189px" title="" xmlns:asp="#unknown" />
            <asp:dropdownlist runat="server" id="DropDownList1" xmlns:asp="#unknown">
            onClick="calShow();"></asp:dropdownlist>
            <asp:calendar id="Calendar1" runat="server" autopostback="true" xmlns:asp="#unknown">
                onselectionchanged="Calendar1_SelectionChanged"></asp:calendar>
		</form></form>


Javascript


Javascript

 window.onload = function loadw() {
		    document.getElementById('Calendar1').style.display = 'none'
		        
}
 function calShow() {
		        document.getElementById('Calendar1').style.display = 'block'
		    }



C#



C#

protected void Page_Load(object sender, EventArgs e)
   {

       if (!IsPostBack)
       {
           DropDownList1.Items.Add("click me");
       }
   }


   protected void Calendar1_SelectionChanged(object sender, EventArgs e)
   {
       DropDownList1.Items[0].Text = Calendar1.SelectedDate.ToShortDateString();
   }


这篇关于从日历显示到DropDownList中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆