I have been working with MVC a little while now (2 months) and am loving it for the most part. I have come across a few instances where I cannot share values of variables between languages. For example.
In javascript/Jquery and so on I can set cookies. But the server cant get at them.
In C# / Razor I can set Query strings, ViewBags, ViewData, Sessions ect. But because this is server side, clientside javascript cant get at them.
What I want to know is, if there is a reasonably simple way I can set a variable like a string in C# or javascript, and read it either pre or post back (doesnt matter) in the other language (ie, a c# Razor variable read by Javascript, or vice versa).
I have not had need to use Json or XML yet with AJax. But if this would help I would consider it. I am new to all this so please forgive my ignorance and thank you for your help.
C# -> JS
Put variables in hidden input fields or data-* attributes and then just Javascript or jQuery to retrieve those values.
JS -> C#
Either use ajax to send stuff back or you could set the values of hidden inputs and then just do a normal form POST to the server.