Sanoop Sanoop -3 years ago 93
jQuery Question

Assign javascript variable to c# variable

How to assign a javascript variable value to c# variable. I am working in MVC3 and need to do the same in the view.

Answer Source

Javascript is run on the client-side. C# on the server. Therefore the C# code has completed long before any javascript runs.

To do what you require you would need to make an AJAX request in JS to a C# endpoint containing the data required.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download