Reputation: 355
In my aspx code I have something like this
if(AnId == <%=MyCodebehindObject.MyId%>)
{
// stuff
}
The code is working: I can get the value from the codebehind variable. However, I'm getting a "Syntax error" warning right at the end of the first line.
I can "fixed it" by enclosing the variable with quotes, but this will make my variable a string, and I'm expecting an int. That will work just fine, the javascript will cast it for comparison, but I think that is just stupid and I was trying to find the write way of doing it.
Any ideas?
Upvotes: 0
Views: 326
Reputation: 1916
you need to wrap the javascript code behind in quotes
if(AnId == '<%= MyCodebehindObject.MyID%>'){
// stuff
}
Upvotes: 3