bala3569
bala3569

Reputation: 11010

how to pass a value from javascript variable to c# variable in asp.net mvc

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

Answers (1)

Satpal
Satpal

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

Related Questions