I have an annoying issue that I'd like to resolve. On my page, I have some Javascript that I need for sending/receiving messages through SignalR. THat page works just like it should, but in the VS2012 IDE I always get a warning about a Syntax Error in the code. This is the code in my View:
$(function ()
{
var usr = $.connection.paMessageHub;
// I cut out the inner code of the following function
$.connection.hub.start().done(function () { });
function sendValue = function (StationId, DataPointId, Value)
{
usr.server.sendValue(StationId, DataPointId, Value);
};
usr.client.updateValue = function (StationId, DataPointId, NewValue)
{
if (StationId == @ViewBag.StationId )
{
updateValues(StationId, DataPointId, NewValue);
}
};
I know there's obviously missing a closing curly bracket in the second last line, but the code just runs perfectly when it is exactly like that. The syntax highlighting says Syntax Error on the closing bracket of
if (StationId == @ViewBag.StationId )
and also says "')' expected" on the semicolon in the line
updateValues(StationId, DataPointId, NewValue);
Is this a bug or am I missing something important? When I insert a closing curled bracket in the second last, the script does not work any more. Thanks for your help!
Update: this simplified example shows the same error:
if ( 1 == @ViewBag.StationId )
{
alert("Test!");
}