在文本框中弹出日历 [英] pop up calender in a textbox
本文介绍了在文本框中弹出日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果提交了特定日期,例如1991年7月6日
输出结果应按21年,3个月,113天的顺序显示在标签中
if a particular date is submited eg 7/6/1991
the out put should be displayed in a labe as follows 21years,3months,113days
is it possible
推荐答案
DateTime Date = new DateTime(2010,9,10);
DateTime Date2 = DateTime.Now;
TimeSpan Diff = Date2 - Date;
int years = Diff.Days / 365;
int Months = years / 12;
double Days = Diff.Days % 365 ;
Console.WriteLine("{0} Years - {1} Months - {2} days ",years,Months, Days);
Console.ReadLine();
是的.
试试看:
HTML:
Yes it''s possible.
Try this out:
HTML:
<asp:textbox id="txtDate" runat="server" xmlns:asp="#unknown" />
<cc1:calendarextender id="CalendarExtender1" runat="server" xmlns:cc1="#unknown">
OnClientDateSelectionChanged="dateSelectionChanged"
TargetControlID="txtDate" PopupButtonID="imgCalendar">
</cc1:calendarextender>
Javascript:
Javascript:
<script type="text/javascript">
function dateSelectionChanged(sender, args){
var selectedDate = sender.get_selectedDate();
/*Do your calculations here. Get the result and set the value to the textbox*/
document.getElementById("txtDate").value = selectedDate;
}
</script>
--Amit
--Amit
这篇关于在文本框中弹出日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文