In the MVC View code below, isLoggedInDb is underlined in green with a tooltip displaying Expected ';'. There clearly is a ;, and it is hard to Google for ; on top of it. I've seen that others have problems creating JavaScript serverside in this manner, so maybe it's not best practice. Should this be ignored, or is there a legitimate reason for Intellisense to complain?
@* SHTML Code Above *@
<script type="text/javascript">
@{
string isLoggedInDb;
if(Session["isLoggedInDb"] != null)
{
if(Session["isLoggedInDb"].ToString() == "1")
{
isLoggedInDb = "1";
}
else
{
isLoggedInDb = "0";
}
}
}
var dblogin=@(isLoggedInDb);
@*....etc*@
}
Edit:
It just occurred to me that building JavaScript programatically, probably is not the best idea, since it might be considered best practice to keep JavaScript in separate files, which are often cached. I think I should program hidden variables in the HTML that JavaScript reads instead. Maybe someone can confirm this.