views:

171

answers:

3

I have an aspx page that my colleague designed for me to stick on the back end. I made a few alterations to the page, adding various controls and things - and now the compiler doesn't recognize any of the controls on the page! The Intellisense is working just fine - I can type txtName. and as I push the . all the properties of a TextBox pop up as normal... but when I try compile, the compiler says "Name 'txtName' is not declared".

There's obviously a secret switch somewhere. Any ideas what it might be?

EDIT: I just realized the difference between this form and every other form in the project: there's no .aspx.designer.vb file. Any idea how to force generation of this file?

A: 

Sounds like it cannot find the code behind file.

It may be that you have a hardcode path somewhere, if you have the code in a different directory than you colleague, then you could get this problem.

If this is what is causing the problem then there are 2 ways to fix it:

  • place all code in same directory structure
  • use relative paths

It could also be that you have not copied all the required files. Try searching for txtName in your code.

Shiraz Bhaiji
Nope, everything is in one folder.
Shaul
Are you able to find the file that defines txtName?
Shiraz Bhaiji
Yes. It's in the aspx file.
Shaul
+2  A: 

I have had a similar problem and it came down to the namespace declaration for the code behind file in the ASPX file

<%@ Page Language="VB" MasterPageFile="~/AdminMasterPage.master" AutoEventWireup="false"
    CodeFile="AdminConsoleAudit.aspx.vb" Inherits="AdminConsoleAudit" Title="Untitled Page"
    StylesheetTheme="cs" Strict="true" %>

This has to change to a

<%@ Page Language="VB" MasterPageFile="~/AdminMasterPage.master" AutoEventWireup="false"
    CodeFile="<namespaceHere>.AdminConsoleAudit.aspx.vb" Inherits="AdminConsoleAudit" Title="Untitled Page"
    StylesheetTheme="cs" Strict="true" %>

HTH

Dean
Thank you! It was the namespace!
Shaul
Actually it wasn't - my mistake... :( How I wish it were that easy...
Shaul
A: 

Got the answer! The .aspx.designer.vb file was missing. And here is how to get it back.

Shaul