jquery - MVC: How do I set a C# static variable from within a javascript block? -


i have function able make changes 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 way able access c# static class within (what believe be) jquery script? i'm new mvc , web development in general. advice welcome on becoming better dev.

@regionswitch._currentregion = selecteditem; 

the above not work either , appears in chrome's javascript console = selecteditem;

as @billcheng , @stephen said, trying do post request jquery.

this how implement post request (ajax) on jquery.

on asp.net mvc side, actions work same regardless of input being ajax or not. have implement action parameters in such way match post parameters. here's article model binding.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -