ITsolutionWizard
asked on
mvc layout >> viewbag >> to Js
I have mvc project with one layout cshtml with some js codes. My goal is to take the parameter (viewbag) value to js file on layout.cshtml.
I try the codes below and "test" does not shown any value when I open the browser >> view source
Do you know how to fix it?
Thanks,
layout.cshtml
<script>
var test = @ViewBag.showMe
var locations =
[
test
[locationData('listings-si ngle-page. html', 'http://localhost:29792/images/listing-item-01.jpg', "Tom's Restaurant", '964 School Street, New York', '3.5', '12'), 40.94401669296697, -74.16938781738281, 1, '<i class="im im-icon-Chef-Hat"></i>'],
[locationData('listings-si ngle-page. html', 'http://localhost:29792/images/listing-item-02.jpg', 'Sticky Band', 'Bishop Avenue, New York', '5.0', '23'), 40.77055783505125, -74.26002502441406, 2, '<i class="im im-icon-Electric-Guitar">< /i>'],
[locationData('listings-si ngle-page. html', 'http://localhost:29792/images/listing-item-03.jpg', 'Hotel Govendor', '778 Country Street, New York', '2.0', '17'), 40.7427837, -73.11445617675781, 3, '<i class="im im-icon-Home-2"></i>'],
];
</script>
Home
Controller:
public ActionResult Index()
{
ViewBag.showMe = " [locationData('listings-si ngle-page. html', 'http://localhost:29792/images/listing-item-01.jpg', "Tom's Restaurant", '964 School Street, New York', '3.5', '12'), 40.94401669296697, -74.16938781738281, 1, '<i class="im im-icon-Chef-Hat"></i>']," ;
return View(EventFleetList());
}
I try the codes below and "test" does not shown any value when I open the browser >> view source
Do you know how to fix it?
Thanks,
layout.cshtml
<script>
var test = @ViewBag.showMe
var locations =
[
test
[locationData('listings-si
[locationData('listings-si
[locationData('listings-si
];
</script>
Home
Controller:
public ActionResult Index()
{
ViewBag.showMe = " [locationData('listings-si
return View(EventFleetList());
}
ASKER
Any Helps?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it does not work
ASKER