How to?
4 Apr 2018 / 1 minute to read
Render TimePicker from Code behind
TimePicker can be rendered from the code behind by initializing the required properties in controller and passing those properties via ViewData or Model to the client side.
The following code illustrates the initialization of TimePicker properties in the controller.
//Namespace to get the JavaScript (TimePicker) component properties
using Syncfusion.JavaScript.Models;
namespace MvcApplication.Controllers
{
public class TimePickerController : Controller
{
// GET: TimePicker
public ActionResult TimePickerFeatures()
{
//Initializing the TimePicker model
TimePickerProperties TimeObj = new TimePickerProperties();
//Initializing the datasource and other properties
TimeObj.Width = "300px";
TimeObj.Interval= 60;
TimeObj.Value = "10:10 AM";
//Passing TimePicker properties using the ViewData
ViewData["TimeModel"] = TimeObj;
return View();
}
}
}
Binding the TimePicker properties passed via ViewData from the controller in the client side as below.
@{
Html.EJ().TimePicker("searchCustomer",(Syncfusion.JavaScript.Models.TimePickerProperties)ViewData["TimeModel"]).Render();
}
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page