C# 如何使 CalendarExtender StartDate 属性采用当前日期?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8863914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I make CalendarExtender StartDate attribute take the current date?
提问by Filip
I thought something like this
我想过这样的事情
<ajaxToolkit:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
TargetControlID="txtDatumPoaganje" Format="MM/dd/yyyy" StartDate=<%=DateTime.Now%>>
But it doesnt work. I can make something similar with JavaScript and alert message:
但它不起作用。我可以用 JavaScript 和警报消息做类似的事情:
how to disable previous dates in CalendarExtender control through its render event?
如何通过其渲染事件禁用 CalendarExtender 控件中的先前日期?
but it's not the same.
但它不一样。
采纳答案by user1231231412
Try SelectedDate instead of StartDate.
尝试 SelectedDate 而不是 StartDate。
Also, the link below says you can't set selecteddate from the html side, instead you must do it from code-behind.
此外,下面的链接说您不能从 html 端设置 selecteddate,而必须从代码隐藏中进行设置。
I haven't confirm this however. http://forums.asp.net/t/1293771.aspx/1
然而,我还没有证实这一点。 http://forums.asp.net/t/1293771.aspx/1
回答by Brissles
Assuming you're trying to only show dates from DateTime.Nowonwards, this may help you: Disable previous Dates in ajaxToolkit CalendarExtender
假设您尝试只显示从DateTime.Now以后的日期,这可能对您有所帮助:禁用 ajaxToolkit CalendarExtender 中的先前日期
回答by user3578442
you can put this in the load page
你可以把它放在加载页面
TextBox2_CalendarExtender.StartDate = DateTime.Now.Date;
TextBox2_CalendarExtender.StartDate = DateTime.Now.Date;

