Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 814
NibblyPig Avatar asked Dec 21 '09 16:12

NibblyPig


2 Answers

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.

like image 127
NibblyPig Avatar answered Nov 20 '22 21:11

NibblyPig


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.

like image 24
womp Avatar answered Nov 20 '22 20:11

womp