1

lets say i have a javascript variable such as:

var something = "information";

I now want to do things with this variable in Razor

@string something2 = something;

I would like to do something similar to the above code, any ideas?

tereško
  • 58,060
  • 25
  • 98
  • 150
brian4342
  • 1,265
  • 8
  • 33
  • 69
  • This won't work. For more information, read http://stackoverflow.com/questions/15991161/pass-js-variable-or-inout-value-to-razor, http://stackoverflow.com/questions/6500941/setting-razor-variables-in-javascript or http://stackoverflow.com/questions/18011016/how-to-use-javascript-variable-in-razor and try to understand the basic principles of client and server side code. – Olaf Jan 26 '14 at 17:15

1 Answers1

2

You wont be able to convert JavaScript variable to a Razor variable. Where 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.

Satpal
  • 132,252
  • 13
  • 159
  • 168