I have this query in the controller:
DataClasses1DataContext behzad = new DataClasses1DataContext();
var query = (from p in behzad.ImagePaths
select new
{
p.name
}).ToList();
ViewBag.movies = query;
return View();
and write this java script code in view page:
function behi() {
@{
var behzad = ViewBag.movies;
}
alert('@(behzad)');
}
that java script code show me this:
how can i write java script code for show controller query result?thanks all.
var behzad = @Html.Raw(Json.Encode(ViewBag.movies)); alert(behzad);
(and not wrapped in@{ ... }
)