Using a javascript variable within Razor
问题 I am aware that Razor is server side and Javascript client side. I am trying to workaround this. Here's what I wanted: RAZOR: if (count > 0) { t.Add().Text("Yeah") ... ... } } But that count is defined at the beginning of the View, like this: @{ int count = 2; } But I can't define it like that: the value for count is on a javascript variable, set on document.ready . Then, I want to use it in the Razor if condition. Is it possible to workaround this? 回答1: Simply No , The reason is same server