How do I set the maskededitvalidator MinimumValue property to today?

1.1k Views Asked by At

I am using an AJAX Control Toolkit: 'maskededitvalidator' to validate a textboxe's date entry. I am trying to set the minimum value programatically to today's date. I have tried both adding it to the source (and calling Page.DataBind()) or setting it in the code behind and niether work. No error, just the validation does not work. If I change the 'MinimumValue' property to a hardcoded value it works just fine. Any ideas? Thanks!

In the source directly on the control:

MinimumValue='<%# DateTime.Now.Date.ToString %>'

In the server code:

Me.txtDateMEV.MinimumValue = DateTime.Now.ToShortDateString()
2

There are 2 best solutions below

0
On BEST ANSWER

I was never able to get the binding systax working in the source, but I did get it working in the code behind like below:

Me.txtDateMEV.MinimumValue = DateTime.Now.ToShortDateString()

I had a CSS style which was erasing the current date if it was left blank and did not have a default date set. Once I updated the CSS not to set 'display:none' for the .AJAXCalendar .ajax__calendar_today style, then the code above worked. So half fixed my issue because CSS was preventing the MinimumValue code to apply. However I really wanted to be able to use the binding syntax but I could never get it to work.

0
On

I think this is more likely a "calendar" issue than a "maskedit" one.

Maybe you should try some Calendar option just like the example on Calendar Example. Check out the Calendar with date range, it looks like the problem you have.