简体   繁体   English

ASP比较验证器在发布后不能采用当前日期

[英]ASP compare validator cannot take current date after publish

I made an asp.net 4.5 web form application. 我做了一个asp.net 4.5 Web表单应用程序。 In my app, one webform has a compare validatior control. 在我的应用程序中,一个webform具有compare validatior控件。 Here is my aspx code: 这是我的aspx代码:

aspx代码段

Here's my aspx.cs code for that validator: 这是我的验证器的aspx.cs代码:

        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 ; 但是当我在smarterasp中发布web form application时; I get this error whenever I go the page using compare validator: 每当我使用比较验证器转到页面时,都会收到此错误:

错误

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. 该应用程序在我的Visual Studio 2017中运行良好。由于某些特殊原因,我无法使用javascript

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. 现在我的页面工作正常。

PS: I found this link very useful to determine which culture to use for different types of format. PS:我发现链接对于确定将哪种文化用于不同类型的格式非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM