I am trying to store a Knockout variable's value in Razor server side code. Something like this
@{
String test = KNOCK_OUT_VARIABLE;
}
in a .cshtml
file.
I am trying to store a Knockout variable's value in Razor server side code. Something like this
@{
String test = KNOCK_OUT_VARIABLE;
}
in a .cshtml
file.
This is not possible / you're looking at this the wrong way.
You're confused about the differences / border / gap / relation between server side and client side programming (see also this PHP version of a related question). To get Knockout values (client side) to your Razor and/or Controllers you need to GET
or POST
something, including the client side value in your request.
You should probably read up on how client and server interaction work in general, and/or follow some tutorials. The Knockout tutorials are pretty good and have a relevant tutorial about loading/saving data.