[index.cshmtl]
@model CoreEJ2.Controllers.HomeController.DateRange
<form id="form1" method="post">
<ejs-calendar id="calendar" value="Model.value" change="onChange">
<input type="hidden" id="hide" name="value" />
</ejs-calendar>
<button>Submit</button>
</form>
<script>
function onChange(args) {
Values(args);
}
function Values(args) {
var option = document.getElementById("hide");
option.value = "";
var calendar = (args.type === undefined) ? args : args.type;
if (calendar.value) {
option.value = calendar.value.toDateString();
}
document.getElementById('form1').appendChild(option);
}
</script> |
public class DateRange
{
public DateTime? value { get; set; }
}
DateRange Instance = new DateRange();
public IActionResult Index()
{
Instance.value = DateTime.Now;
return View(Instance);
}
[HttpPost]
public IActionResult Index(string val)
{
//request to get the post data from the form post from value
string value = Request.Form["value"];
//converting string value to DateTime object
Instance.value = Convert.ToDateTime(value);
return View(Instance);
}
|
<ejs-datetimepicker id="datetimepicker"></ejs-datetimepicker>
<script>
document.addEventListener('DOMContentLoaded', function () {
datetimepicker = document.getElementById('datetimepicker').ej2_instances[0];
var L10n = ej.base.L10n;
L10n.load({
'is': {
'datetimepicker': {
placeholder: 'Veldu dagsetningu tímans',
today: 'í dag'
}
}
});
datetimepicker.locale = 'is';
loadCultureFiles('is');
});
function loadCultureFiles(name) {
var files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json'];
if (name === 'ar') {
files.push('numberingSystems.json');
}
var loader = ej.base.loadCldr;
var loadCulture = function (prop) {
var val, ajax;
if (name === 'ar' && prop === files.length - 1) {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../scripts/cldr-data/supplemental/' + files[prop], 'GET', false);
} else {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', false);
}
ajax.onSuccess = function (value) {
val = value;
};
ajax.send();
loader(JSON.parse(val));
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
}
</script> |