Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

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-single-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-single-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-single-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-single-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());
        }

Open in new window

Avatar of ITsolutionWizard
ITsolutionWizard
Flag of United States of America image

ASKER

Any helps?
Any Helps?
ASKER CERTIFIED SOLUTION
Avatar of Shinesh Premrajan
Shinesh Premrajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it does not work