ajaxcontroltoolkitmaskededitvalidator

How do I set the maskededitvalidator MinimumValue property to today?


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()

Solution

  • 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.