How can I make CalendarExtender StartDate attribut

2019-06-24 16:52发布

问题:

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:

how to disable previous dates in CalendarExtender control through its render event?

but it's not the same.

回答1:

Try SelectedDate instead of StartDate.

Also, the link below says you can't set selecteddate from the html side, instead you must do it from code-behind.

I haven't confirm this however. http://forums.asp.net/t/1293771.aspx/1



回答2:

you can put this in the load page

TextBox2_CalendarExtender.StartDate = DateTime.Now.Date;



回答3:

Assuming you're trying to only show dates from DateTime.Now onwards, this may help you: Disable previous Dates in ajaxToolkit CalendarExtender