Last post Jan 06, 2010 02:19 PM by RemithR
Jan 06, 2010 01:15 PM|ipshing|LINK
I have a scenario where I've created a custom control that connects to a database and gets records from the last X number of months where X is any desired number. I use a "MinDate" parameter to determine how far back to look.
When I add my control to my page, how can I set the "MinDate" parameter to something like "DateTime.Today.AddMonths(-3)"? I've tried:
MinDate="<%= DateTime.Today.AddMonths(-3) %>"
but that clearly doesn't work. Help, please!
Jan 06, 2010 02:07 PM|karthi128|LINK
set it from server side
ctrl.MinDate = DateTime.Today.AddMonths(-3)
Jan 06, 2010 02:10 PM|RemithR|LINK
MinDate='<%# DateTime.Now.AddMonths(-3) %>'
Jan 06, 2010 02:12 PM|ipshing|LINK
Fair enough. Is there no way to do that in the aspx page itself? I don't care either way, I'm just asking out of curiosity.
Jan 06, 2010 02:19 PM|RemithR|LINK
var calendar = <%=UserControl1.ClientID%>;
var currentDate = new Date();
var newDate = new Date(currentDate.getYear(), currentDate.getMonth() - 3, currentDate.getDate());
calendar.MinDate = newDate;