Error: String was not recognized as a valid DateTime in IIS Server in ASP.Net

Last Reply on Jan 16, 2017 09:46 AM By dharmendr

Posted on Jan 16, 2017 07:30 AM

Here is the datepicker:

 

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/themes/humanity/jquery-ui.css"
    rel="stylesheet" type="text/css" />

<script type="text/javascript">
    var $ = jQuery.noConflict();
    $(function () {
        $("[id$=txtExpDate]").datepicker({

            //dateFormat: 'DD, d MM, yy',
          //  dateFormat: 'mm-dd-yy',
            //buttonImageOnly: true,
            //buttonImage: 'http://jqueryui.com/demos/datepicker/images/calendar.gif'
        });
    });
    $(function () {
        $("[id$=txtManDate]").datepicker({

            //dateFormat: 'DD, d MM, yy',
          //  dateFormat: 'mm-dd-yy',
            //buttonImageOnly: true,
            //buttonImage: 'http://jqueryui.com/demos/datepicker/images/calendar.gif'
        });
    });
</script>

Here is the code for convert:

 

DateTime dt2 = Convert.ToDateTime(txtManDate.Text);

DateTime dt3 = Convert.ToDateTime(txtExpDate.Text);

The server database i am using for insert value..this working very well in local code...but not working in server.

Error is:

String was not recognized as a valid DateTime.

 

What should  i do??

 

You are viewing reply posted by: dharmendr on Jan 16, 2017 09:46 AM.
Posted on Jan 16, 2017 09:46 AM

Hi manoj150,

1) Change the datetime format of your server from

Control Panel -> Regional and Language Options -> Advanced

2) Open IIS and follow below steps:

  •  Click on you Website
  •  Select .NET GLOBALIZATION option
  •  From Culture tab, select required Culture and UI Culture.
  •  Finally iisreset.