hi
I use below code to enter date into text box:
<script type="text/javascript">
$(function () {
$("#TxtdateC").mask("0000/00/00");
$("#TxtdateE").mask("0000/00/00");
$('[id*=TxtdateC]').on("change", function () {
var reg = /^(13|15)\d\d[\-\/.](0[1-9]|1[012])[\-\/.](0[1-9]|[12][0-9]|3[01])$/;
if (!reg.test($('[id*=TxtdateC]').val())) {
alert("Please enter valid date format");
$('[id*=TxtdateC]').val('');
$('[id*=TxtdateC]').focus();
}
});
$('[id*=TxtdateE]').on("change", function () {
var reg = /^(13|20)\d\d[\-\/.](0[1-9]|1[012])[\-\/.](0[1-9]|[12][0-9]|3[01])$/;
if (!reg.test($('[id*=TxtdateE]').val())) {
alert("Please enter valid date format");
$('[id*=TxtdateE]').val('');
$('[id*=TxtdateE]').focus();
}
});
});
</script>
here user can enter date to shamsi like:
1396/02/19
now I want when they click button to save this date into database it will save this date to 2017-09-17 into database
I test this code:
System.Globalization.PersianCalendar shamsi = new System.Globalization.PersianCalendar();
DateTime startDate = new DateTime(int.Parse(TxtdateC.Text), shamsi);
but this error happen:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1503: Argument 2: cannot convert from 'System.Globalization.PersianCalendar' to 'System.DateTimeKind'
Source Error:
|
Line 600: //_cmd.Parameters.AddWithValue("@Expiredate", TxtdateE.Text);
Line 601: _cmd.Parameters.AddWithValue("@code", Lblcode.Text);
Line 602: DateTime startDate = new DateTime(int.Parse(TxtdateC.Text), shamsi);
Line 603: _cmd.Parameters.AddWithValue("@Contractdate", startDate);
Line 604:
|
how I can change persiandate to english and save into database?
best regards
neda