I am developing a web application in asp.net mvc 3.
I am very new to it. In a view using razor, I'd like to declare some local variables and use it across the entire page. How can this be done?
It seems rather trivial to be able to do the following action:
@bool isUserConnected = string.IsNullOrEmpty(Model.CreatorFullName);
@if (isUserConnected)
{ // meaning that the viewing user has not been saved
<div>
<div> click to join us </div>
<a id="login" href="javascript:void(0);" style="display: inline; ">join</a>
</div>
}
But this doesn't work. Is this possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…