I have this function that I would like to be able to make changes to a static class.

$("#DDLRegion").change(function () {

     var selectedItem = $(this).val();
     ViewBag.Region = selectedItem;
     @RegionSwitch.setRegion(ViewBag.Region);

     switch (selectedItem) {
        case 'Place':
           window.location.href = '@Url.Action("Index", "Place")'
           break;
        case 'Thing' :
           window.location.href = '@Url.Action("Index", "Thing")'
           break;
        case 'Region' :
           window.location.href = '@Url.Action("Index", "Region")'
           break;
        default:
           window.location.href = '@Url.Action("Index", "Place")'
           alert("Blarg");
           break;
     }
  });

Is there a way to be able to access a C# static class from within (what I believe to be) a jQuery script? I'm new to MVC and web development in general. Any advice is also welcome on becoming a better dev.

@RegionSwitch._currentRegion = selectedItem;

The above does not work either and appears in Chrome's JavaScript console as = selectedItem;

Related posts

Recent Viewed