We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Just wondering...

Thread ID:

Created:

Updated:

Platform:

Replies:

130750 May 30,2017 06:43 PM Jun 1,2017 09:21 AM ASP.NET MVC 1
loading
Tags: DateTimePicker
Bernard Jurlina
Asked On May 30, 2017 06:43 PM

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.

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On June 1, 2017 09:21 AM

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"; 
            Session["data"] = dt; 
            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(); 
            var datas = Session["data"] as 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;