GANI
GANI

Reputation: 2049

Kendo UI error in MVC 5

Upgraded my applicaiton from MVC 3 to mVC 5 and kendo UI to Q1 2014. Got this exception

"An exception of type 'System.NullReferenceException' occurred in App_Web_field.master.78ead928.iz8p2r9r.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object."

here is my .cshtml file

@(Html.Kendo().Grid<CustomerModel>()
.Name("grid")
.Columns(columns => {
    columns.Bound(p => p.Sender);
    columns.Bound(p => p.Body);
})
.Selectable(s => s.Mode(GridSelectionMode.Single))
.Groupable()
.Events(ev => { ev.DataBound("onDataBound").Change("onChange"); })
.DataSource(dataSource => dataSource
    .Ajax()
    .ServerOperation(false)
    .PageSize(20)
    .Model(model =>
    {
        model.Field(c => c.Sender).Editable(false);
        model.DateTimeField(c => c.Sent).Editable(false);
    })
        .Read(read => read.Action("GetCustomers", Html.CurrentControllerName()))
)

)

intellisense says System.Web.WebPages.Html.HtmlHelper doesnot contain a definition for kendo.

here is the stack trace

               [NullReferenceException: Object reference not set to an instance of an object.]
       ASP.views_inputbuilders_displaytemplates_field_master.__Render__control1(HtmlTex    tWriter __w, Control parameterContainer) in 
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +268
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
    System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +53
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1386

Upvotes: 0

Views: 1927

Answers (2)

Matt Millican
Matt Millican

Reputation: 4054

This line tells me you're missing the namespace in the view web.config:

intellisense says System.Web.WebPages.Html.HtmlHelper doesnot contain a definition for kendo.

Make sure this line is added in your views/web.config file, under the namespaces element

<add namespace="Kendo.Mvc.UI"/>

Note that if you are using areas, this must be in the web.config of the views folder in each area.

Upvotes: 1

David Shorthose
David Shorthose

Reputation: 4497

Have you updated the kendo.mvc.dll reference?

Also do you have the Kendo.Mvc.UI namespace in your pages webconfig? (I generally find this is the issue when @html.kendo() is not found by intellisense)

Since you have added the required reference to all logical places then, give the project a clean and rebuild. (If you have had to include the namespace into the views webconfig just restart visual studio to pick up the change - again I find it doesn't always pick up the change straight away)

Other than seeing the project itself it's difficult to give you a root cause of this.

Also make sure you have updated the references to the kendo.js files in your layout page.

(Paul I know this still doesn't answer the question but I am trying to help a fellow developer here with minimal information being provided)

Upvotes: 2

Related Questions