eye
eye

Reputation: 304

Extjs and asp.net mvc integration

Is it possible to access .net variables, resources etc. from exjs script. For instance how to perform sth like:

 items: [{
            text: '@ResourceClass.Text',
        }

or access url by:

 items: [{
            url: '@Url.Content("~/Content/Body.htm")',
        }

Upvotes: 0

Views: 177

Answers (2)

Tom Clarkson
Tom Clarkson

Reputation: 16174

That should work as long as that script is inside a cshtml file. However, the parser can get a bit confused by the similarity of javascript and c# code - when this happens modifying the syntax to

url: '@(Url.Content("~/Content/Body.htm"))',

usually gets the parser to recognize the c# component correctly.

Upvotes: 1

Muhammad Adeel Zahid
Muhammad Adeel Zahid

Reputation: 17794

you can mix your .NET code with js code in your views but not in external javascript files and extjs is another js library so you can mix extjs code in your views.

Upvotes: 0

Related Questions