|
@model Syncfusion_EJ2_Core_App.Controllers.DateRange
<div class=" control-section">
<div id="wrapper" class="daterangepicker-section">
<div id="daterangepicker-control">
<form method="post">
<ejs-daterangepicker id="daterangepickerFor" ejs-for="@Model.value"></ejs-daterangepicker>
<div id="errorMessage">
<span asp-validation-for="value"></span>
</div>
<div id="submitbutton">
<ejs-button id="submitButton" content="Submit"></ejs-button>
</div>
</form>
</div>
</div>
</div> |
|
public class DateRange
{
[Required(ErrorMessage = "Please enter the value")]
public DateTime[] value { get; set; }
}
public class HomeController : Controller
{
DateRange DateRangeValue = new DateRange();
public IActionResult Index()
{
DateRangeValue.value = new DateTime[] { new DateTime(2020, 03, 03), new DateTime(2021, 09, 03) };
return View(DateRangeValue);
}
[HttpPost]
public IActionResult Index(DateRange model)
{
//posted value is obtained from the model
DateRangeValue.value = model.value;
var stratDate = model.value[0];
var endDate = model.value[1];
return View(DateRangeValue);
}
} |
Hi Muhamad,Greetings from Syncfusion support.We can get the start date and end date value from the DateRangePicker component’s value property as a index since it is a DateTime array. Please refer the below code example.[Index.cshtml]
@model Syncfusion_EJ2_Core_App.Controllers.DateRange<div class=" control-section"><div id="wrapper" class="daterangepicker-section"><div id="daterangepicker-control"><form method="post"><ejs-daterangepicker id="daterangepickerFor" ejs-for="@Model.value"></ejs-daterangepicker><div id="errorMessage"><span asp-validation-for="value"></span></div><div id="submitbutton"><ejs-button id="submitButton" content="Submit"></ejs-button></div></form></div></div></div>
[HomeController.cs]
public class DateRange{[Required(ErrorMessage = "Please enter the value")]public DateTime[] value { get; set; }}public class HomeController : Controller{DateRange DateRangeValue = new DateRange();public IActionResult Index(){DateRangeValue.value = new DateTime[] { new DateTime(2020, 03, 03), new DateTime(2021, 09, 03) };return View(DateRangeValue);}[HttpPost]public IActionResult Index(DateRange model){//posted value is obtained from the modelDateRangeValue.value = model.value;var stratDate = model.value[0];var endDate = model.value[1];return View(DateRangeValue);}}
Please find the sample from the below link.Sample Link: https://www.syncfusion.com/downloads/support/forum/151775/ze/Syncfusion_EJ2_Core_App_151775_daterangepicker1002407681Regards,Berly B.C
Hi Alejandro,
Thanks for the update.
We have checked your reported query. But unfortunately the reported issue is not replicated in our end. We have attached the video demonstration for your reference.
Kindly check with the above video. If issue still exists in your end, please provide the below details, which helps us to check and update the solution at earliest.
- Provide video demonstration with issue replication procedure.
- In which case, the end date is returns null.
- Try to provide the issue replicating sample.
Regards,Ponmani M
Hi Alejandro,
Thanks for the update.
We have checked your reported query. But unfortunately the reported issue is not replicated in our end. We have attached the video demonstration for your reference.
Kindly check with the above video. If issue still exists in your end, please provide the below details, which helps us to check and update the solution at earliest.
- Provide video demonstration with issue replication procedure.
- In which case, the end date is returns null.
- Try to provide the issue replicating sample.
Regards,Ponmani M
|
protected void Application_BeginRequest(Object sender, EventArgs e)
{
CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"; // required culture format
newCulture.DateTimeFormat.DateSeparator = "/"; // required separator
Thread.CurrentThread.CurrentCulture = newCulture;
} |