ASP compare validator cannot take current date after publish

179 Views Asked by At

I made an asp.net 4.5 web form application. In my app, one webform has a compare validatior control. Here is my aspx code:

aspx code snippet

Here's my aspx.cs code for that validator:

        protected void Page_Load(object sender, EventArgs e) {
        if (!IsPostBack) {
            string currentDate = DateTime.Now.ToString("dd/MM/yyyy");                
            ComparevalidatorDOB.ValueToCompare = currentDate;
        }
    }

It works fine on my PC. But when I published the web form application in smarterasp; I get this error whenever I go the page using compare validator:

error

How can I solve this error? Please note that I'm getting this error after publishing the application. The app works fine in my visual studio 2017. And I can't use javascript for some particular reason.

1

There are 1 best solutions below

0
On

Found a solution to my problem. Here it is... I added the appropriate culture for date on the top of the page where the problem was occurring.

<%@ Page Title="" Culture="bn-BD" %>

Now my page works fine.

P.S: I found this link very useful to determine which culture to use for different types of format.