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.
Syncfusion Feedback

Editor Templates with Syncfusion Controls

Thread ID:

Created:

Updated:

Platform:

Replies:

130816 Jun 5,2017 12:08 PM UTC Jun 12,2017 12:29 PM UTC ASP.NET MVC 4
loading
Tags: DatePicker
Emrah
Asked On June 5, 2017 12:08 PM UTC

Hello,
I want to override default MVC editor templates (~/Shared/EditorTemplates/). when I add a new view named Date include Syncfusion DatePickerFor, it doesn't work, if I only use DatePicker in this view it works but can't handle when editing. 
What can I do?

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On June 6, 2017 12:39 PM UTC

Hi Emrah, 
Thanks for contacting Syncfusion support. 
We have analyzed your query. We can override the default MVC editor templates and can render the  EJ DatePicker control in EditorTemplates folder by EditorFor control in any view. In the model we can use DateAnnotations link UIHint and DataType attributes to state the template formats to use. 
myModel.cs 
using System.ComponentModel.DataAnnotations; 
 
public class MyViewModel 
    { 
    [UIHint("WorkAround")] 
        public DateTime Patched { get; set; } 
 
    } 

The editorFor control uses the model and goes to partialView WorkAround.cshtml and renders DatePicker. 
Index.cshtml 
@model IDErrorSample.Models.MyViewModel 
@{ 
    ViewBag.Title = "Show Bug"; 
} 
 
@Html.EditorFor(model => model.Patched) 
 

WorkAround.cshtml 
@model DateTime 
@{ 
    var id = Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId("");  
} 
<dl> 
     
    <dd>@Html.EJ().DatePickerFor(m=>m, new Dictionary<string, object> { { "id", id } }).DateFormat("dd/MMM/yyyy")</dd> 
     
</dl> 
 
 
For your convenience, we have prepared a work around sample to meet your requirement. Please, find the sample in the below link. 

Also, use the below links to know more about the sample. 

Please, let us know for any further assistance. 
Regards, 
Shameer Ali Baig S. 


Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On June 6, 2017 12:51 PM UTC

Hi Emrah, 
Sorry, we missed to update the sample in previous update. 
Please, find the sample for editor templates using EJ DatePicker in the below link. 
Sample: Editor Templates  
Regards, 
Shameer Ali Baig S. 


Emrah
Replied On June 9, 2017 06:11 AM UTC

Thank you so much,
Regards.

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On June 12, 2017 12:29 PM UTC

Hi Emrah, 
Most Welcome. 
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.

Warning Icon 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.Close Icon

;