How Can I Render A Partial View Inside an Editor Template?

874 views Asked by At

I am using an edit template for Kendo scheduler called ScheduleEditorTemplate.cshtml which his located in Views/Shared/EditorTemplates

I have a partial view named _POC.cshtml and I need to display that partial view inside the ScheduleEditorTemplate.cshtml. This is a read-only partial view, the user will only view what is there.

When I use the RenderPartial method as follows I get an "invalid template" exception when I try to open the ScheduleEditorTemplate.cshtml from the scheduler. It works without the partial view included.

How can I render a partial view with a different view model into an editor template?

Here's my code to render the partial view within the ScheduleEditorTemplate.cshtml

@{Html.RenderPartial("_POC");}

I am already using this partial view in another view so I know it loads and works correctly there.

I tried this also with the same exception generated:

@Html.Partial("~/Views/EmployeeSchedule/_POC.cshtml")

I can share the code from _POC.cshtml but there's nothing special there; just kendo controls.

1

There are 1 answers

0
Olivier Martial Soro On
@{Html.RenderPartial("_POC");}

And use Ajax to load this partial view:

<script type="text/javascript">  
  $(document).ready(function () {
      $("#div").load('@(Url.Action("POC","ControllerName"))', function(){});
  });
</script>