How to fix “Declaration expected”, “Syntax error”, and “Statement cannot appear outside of a method” errors that appear in a non-sense way in Visual Studio

There might be several different reasons for the generic errors below to appear.

Declaration expected
Syntax error
Statement cannot appear outside of a method

In my case, Visual Studio IntelliSense seemed to be showing these errors in every single line in my code-behind (cs) pages. Including the Page declaration in the ASPX page.


Follow the steps below until you solve the issue. If a step solves the problem, you don’t have to continue with the next step.

  1. Make sure to specify default language in your web.config (<compilation defaultLanguage=”C#”>)
  2. Specify default language in the beginning of your ASPX files (<%@ Page Language=”C#” %>)
  3. Page declarative must be the first line in your ASPX files. There shouldn’t be any lines including comments before your Page declarative (<%@ Page … %>
  4. Exclude the file from the project. Compile. Include it back
  5. Restart Visual Studio and recompile your code


How to use Windows Continuum? (No display adapter or dock needed)

Share your Windows phone’s screen with your PC by following simple steps below.

You don’t need any display adapter or dock to connect to your PC. However, you will need them if you want to use your phone with your TV or monitor.

  1. In your PC, go to “Settings > System > Projecting to this PC“. Select “Available everywhere” or “Available everywhere on secure networks
  2. In your Windows Phone, open the application “Continuum“. Select “Wireless Adapter“. Click “Connect
  3. Select your PC
  4. In your PC, confirm the connection request
  5. You are all set! Enjoy!

More info:

How to enable Internet Explorer 11 document modes?

Even though you have the latest version of Internet Explorer, you may need to render your web applications in different IE engines in order to test your applications’ compatibility in older browsers.

There 5 popular document modes:

  • IE7 (Compatibility Mode)
  • IE8 (Enterprise Mode)
  • IE9
  • IE10
  • IE11 (Edge Mode)

Here are the step by step instructions to turn them on…

Enable IE7 (Compatibility Mode)

  1. Click “Tools > Compatibility View settings”
  2. Select “Display intranet sites in Compatibility View”. This will make sure that intranet websites to be rendered in compatibility mode
  3. If it is an extranet website, type the domain and click “Add”

Enable IE8 (Enterprise Mode):

  1. Click “Tools > Enterprise Mode”

Enable IE9 Mode:

  1. Click “F12” to open “Developer Tools”
  2. Go to “Emulation”. Select “Desktop” in “Browser profile” and “9” in “Document mode”

Enable IE10 Mode

  1. Click “F12” to open “Developer Tools”
  2. Go to “Emulation”. Select “Desktop” in “Browser profile” and “10” in “Document mode”

Enable Edge Mode

  1. If you don’t select any mode above, it will be in Edge mode by default. You can also select “Edge” in “Developer Tools” to make sure.