2

I need pass ViewBag value to java script function in razor. ViewBag filled by string and I use this code but get error that :

Uncaught ReferenceError: IsAirTour is not defined

IsAirTour is value of ViewBag

var RunFilter = function (cls) {
            var $grid = $('#grid');
            $grid.isotope({ filter: '.' + cls + '' })
            SetHeightEls('#grid .All');
        }
        $(document).ready(function () {
            RunFilter(@((string)ViewBag.Cls) ); //Error
        });

How to solve this?

0

1 Answer 1

2

Use this

 RunFilter('@ViewBag.Cls'); //Error

Instead

RunFilter(@((string)ViewBag.Cls) ); //Error
Sign up to request clarification or add additional context in comments.

1 Comment

Better, but you need to explain what you have done too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.