Search code examples
asp.net-mvcknockout.jsknockout-mvc

ASP is not defined at @ko.Apply(Model)


I m trying to bind my model and get error Uncaught ReferenceError: Unable to process binding "value: function (){return ASP._Page_Views_Configuration_Index_cshtml.Model().SomeProperty }" Message: ASP is not defined

View:

@using PerpetuumSoft.Knockout

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/knockout")

@model Asteros.MKD.Controllers.SomeModel
@{
    var ko = Html.CreateKnockoutContext();
}

@ko.Html.TextBox(model => Model.SomeProperty)


@ko.Apply(Model)

bundles:

            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

....

bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
                "~/Scripts/knockout-{version}.js",
                "~/Scripts/knockout.mapping-latest.js",
                "~/Scripts/perpetuum.knockout.js"
                ));

Any ideas?


Solution

  • Use model instead of Model:

    @ko.Html.TextBox(model => model.SomeProperty)