NibblyPig
NibblyPig

Reputation: 52942

Syntax error caused by <%@ Page Language="c#"%> ? ASP.Net

Is this invalid to put in an aspx file? I have some static aspx pages and I want to add a bit of C# to one of them. How can I do this?

I figured just adding

<%@ Page Language="c#"%>

and then using <% %> to put a bit of C# goodness in there, but it says Syntax Error. with a blue wavy line over this code.

Upvotes: 12

Views: 14881

Answers (2)

NibblyPig
NibblyPig

Reputation: 52942

This happens whenever you change the Language attribute of the Page directive. Simply close the file in Visual Studio, and reopen it. The error will go away.

Upvotes: 28

womp
womp

Reputation: 116977

It's not entirely clear from your question, but are you adding multiple Page directives? You can only have one per .aspx file.

Otherwise what you've got there is valid. If your page works fine and VS is still showing it as an error, quit out of VS entirely and restart it.

Upvotes: 1

Related Questions