July 16, 2007

C#/ASP.NET error CS1026: ) expected

If you've used any inline evaluation blocks in your ASP.NET pages, you've probably come across an error similar to this one...
...\PageName.aspx(75): error CS1026: ) expected
When you go to that line on your page, you see that your parenthesis add up.
<%# Eval("TRACKING_INFO").ToString().Replace("|", " "); %>
The culprit is the semicolon at the end of the statement. Delete that and the error will go away.

9 comments:

Mr. Bluesummers said...

WTF?! Why does...why does that work? x__x

Thanks Rom. I was looking at this error, and it was so generic and the context so specific that I didn't think I'd find an answer.

++ points to you! Thanks!

Nirav said...

Thanx I always wondered why wouldn't this work

Unknown said...

VB.net can give the same error, but without the semicolon. What's the fix in that case?

Unknown said...

Very helpful. Thanks a lot.

Vikram said...

hey thanx it works for me too :)

Anonymous said...

Thnx..A lot...

Josh Cain said...

Helped me out too!

Unknown said...

Also, if the evaluation is in quotes '<%#Eval(Name)%>' and if the name contains a colon, error shows up as the string has unclosed colon. Eg
'ASP.NET's Page'

Justin said...

Thank you!