- Home
- Forum
- ASP.NET MVC
- Just wondering...
Just wondering...
Is there some way to hold "configuration", for example, for all DateTimePickerFor controls in all views?
If I have DateTimePickerFor like this:
@Html.EJ().DateTimePickerFor(model => model.DatumOd).Width("250px").Locale("hr-HR").DateTimeFormat("dd.MM.yyyy. HH:mm").ShowRoundedCorner(true)DateTimePickerButtonText(text => text.Today("Danas").TimeNow("Vrijeme sada").Done("Prihvati").TimeTitle("Vrijeme"))
Can this part ".Locale("hr-HR").DateTimeFormat("dd.MM.yyyy. HH:mm").ShowRoundedCorner(true)DateTimePickerButtonText(text => text.Today("Danas").TimeNow("Vrijeme sada").Done("Prihvati").TimeTitle("Vrijeme"))" be somehow globally controlled? So, instead of write that long "config" every time, maybe to be like .Config("DateTimePickerOptions"), where "DateTimePickerOptions" is some kind of JSON to hold that options.
And, when I want to change that for all the DateTImePicker controls, I can do it in just one place.
Thanks.
B.
SIGN IN To post a reply.
1 Reply
SA
Shameer Ali Baig Sulaiman Ali Baig
Syncfusion Team
June 1, 2017 01:21 PM UTC
Hi Bernard,
Thanks for contacting Syncfusion support.
We have checked with your query. We can able to hold the properties of DateTimePickerFor using Session object in a single base controller and then we can use the session objects from other controllers with minimum effort. We have prepared a work around to meet your requirement. In DatePickerController, properties of DatetimePickerFor is stored in session object and it is used by the HomeController.
DatePickerController.cs
| public ActionResult DatePickerFeatures(DateTime_pick model) { DateTime_pick dat1 = new DateTime_pick(); dat1.datepic = DateTime.Now; DateTimePickerProperties dt = new DateTimePickerProperties(); dt.DisplayInline = true; dt.DateFormat = "dd/MMM/yyyy"; return View(model); } |
HomeController.cs
| public ActionResult Index(DateTime_pick model) { DateTime_pick dat1 = new DateTime_pick(); dat1.datepic = DateTime.Now; DateTimePickerProperties dt = new DateTimePickerProperties(); return View(model); } |
DatePickerFeatures.cshtml
| @model SyncfusionMvcApplication5.Models.DateTime_pick <div class="control"> @Html.EJ().DatePicker("DatePick").DateFormat("MM/dd/yyyy").ShowOtherMonths(true).EnableRTL(false).Locale("en-US") @Html.EJ().DateTimePickerFor(model => model.datepic,(Syncfusion.JavaScript.Models.DateTimePickerProperties)Session["data"]) </div> |
Index.cshtml
| @model SyncfusionMvcApplication5.Models.DateTime_pick @Html.EJ().DateTimePickerFor(model => model.datepic, (Syncfusion.JavaScript.Models.DateTimePickerProperties)Session["data"]) |
Session Object will be initialized in a controller which is first invoked by the application and then it can be accessible from all other controller. In the view of corresponding controller, we can use the session data as used in the above code.
Sample: DateTimePicker
Please, use the following links to know more about Session in ASP.NET MVC
Please let us know if you need any further assistance.
Regards,
Shameer Ali Baig S
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
BJ Bernard Jurlina
- May 30, 2017 10:43 PM UTC
- Jun 1, 2017 01:21 PM UTC