Is it possible to initialize a variable in view using razor and then manipulate the value of it using jquery or vice versa?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes,
If you are in a .cshtml view you can do something like this:
But I am not sure if there is a way to pass a JS variable to Razor code, I don’t think so. But you could maybe make an ajax call and pass the JS value.
There is also a nice open source project called RazorJS, you should check it out
http://john.katsiotis.com/blog/razorjs—write-razor-inside-your-javascript-files