Reputation: 11010
Here i have a value in javascript variable and i need to pass this value to c# variable.How to pass this value while loading that cshtml file?
<script type="text/javascript">
var str="value";
</script>
in razor view
var a=str; //c#
Any suggestion??
Upvotes: 0
Views: 983
Reputation: 133453
Short answer is You can't
You wont be able to pass/convert JavaScript variable to a Razor variable. Razor variable is handled by Razor engine where as JavaScript on the other hand is a client side language running on the client.
Razor is a view engine used by the ASP.NET MVC framework running on the server to produce some HTML template.
Upvotes: 1