Visual Studio .NET 2005 reports false error

Discussion in 'ASP .Net' started by tofu.captain, Dec 4, 2006.

  1. tofu.captain

    tofu.captain Guest

    I'm using Visual Studio .NET 2005 with a C# Web Application project. I
    have an ASPX page that uses a MasterPage file for a general site
    layout. That works just fine, but when I run a compile of the ASPX
    page (say default.aspx) with something like:

    <asp:Label id="lblFoo" runat="server" />

    and have it's codebehind have:

    protected void Page_Load(object sender, EventArgs e)
    {
    this.txtFoo.Text = "this works";
    }

    However, when I run a compile, the Error List reports that:
    'Default' does not contain a definition for 'txtFoo'

    when clearly there is. The problem is that the project compiles and
    runs fine, but the error list is reporting an incorrect error. Does
    anyone else have a similar problem with VS.NET 2005? Is this a bug in
    the IDE?

    Some added notes:
    - I do have multiple Default.aspx across my project, but they are in
    different folders and I have checked that all referencing paths are
    correct.
    - I did copy & paste some code from a different page into this ASPX
    page, and started noticing this bug, but I have commented out such code
    and still get this problem running the above example. Is there a bug
    with copying & pasting code from another ASPX page that runs something
    similar to what I have above?

    Thanks so much
    tofu.captain, Dec 4, 2006
    #1
    1. Advertising

  2. tofu.captain

    Chicagoboy27 Guest

    try

    lblFoo.Text = "this works";

    txtFoo does not exist in your project.


    tofu.captain wrote:
    > I'm using Visual Studio .NET 2005 with a C# Web Application project. I
    > have an ASPX page that uses a MasterPage file for a general site
    > layout. That works just fine, but when I run a compile of the ASPX
    > page (say default.aspx) with something like:
    >
    > <asp:Label id="lblFoo" runat="server" />
    >
    > and have it's codebehind have:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > this.txtFoo.Text = "this works";
    > }
    >
    > However, when I run a compile, the Error List reports that:
    > 'Default' does not contain a definition for 'txtFoo'
    >
    > when clearly there is. The problem is that the project compiles and
    > runs fine, but the error list is reporting an incorrect error. Does
    > anyone else have a similar problem with VS.NET 2005? Is this a bug in
    > the IDE?
    >
    > Some added notes:
    > - I do have multiple Default.aspx across my project, but they are in
    > different folders and I have checked that all referencing paths are
    > correct.
    > - I did copy & paste some code from a different page into this ASPX
    > page, and started noticing this bug, but I have commented out such code
    > and still get this problem running the above example. Is there a bug
    > with copying & pasting code from another ASPX page that runs something
    > similar to what I have above?
    >
    > Thanks so much
    Chicagoboy27, Dec 4, 2006
    #2
    1. Advertising

  3. tofu.captain

    tofu.captain Guest

    oops, actually what i have is that, i just wrong my example in this
    topic wrong. but the issue still stands.

    so what i have is:
    <asp:TextBox id="txtFoo" runat="server" />

    codebehind:
    protected void Page_Load(object sender, EventArgs e)
    {
    this.txtFoo.Text = "this works";
    }

    sorry for the misprint.

    Chicagoboy27 wrote:
    > try
    >
    > lblFoo.Text = "this works";
    >
    > txtFoo does not exist in your project.
    >
    >
    > tofu.captain wrote:
    > > I'm using Visual Studio .NET 2005 with a C# Web Application project. I
    > > have an ASPX page that uses a MasterPage file for a general site
    > > layout. That works just fine, but when I run a compile of the ASPX
    > > page (say default.aspx) with something like:
    > >
    > > <asp:Label id="lblFoo" runat="server" />
    > >
    > > and have it's codebehind have:
    > >
    > > protected void Page_Load(object sender, EventArgs e)
    > > {
    > > this.txtFoo.Text = "this works";
    > > }
    > >
    > > However, when I run a compile, the Error List reports that:
    > > 'Default' does not contain a definition for 'txtFoo'
    > >
    > > when clearly there is. The problem is that the project compiles and
    > > runs fine, but the error list is reporting an incorrect error. Does
    > > anyone else have a similar problem with VS.NET 2005? Is this a bug in
    > > the IDE?
    > >
    > > Some added notes:
    > > - I do have multiple Default.aspx across my project, but they are in
    > > different folders and I have checked that all referencing paths are
    > > correct.
    > > - I did copy & paste some code from a different page into this ASPX
    > > page, and started noticing this bug, but I have commented out such code
    > > and still get this problem running the above example. Is there a bug
    > > with copying & pasting code from another ASPX page that runs something
    > > similar to what I have above?
    > >
    > > Thanks so much
    tofu.captain, Dec 4, 2006
    #3
  4. I think the issue here is that VS 2005 has the concept of partial classes.
    The designer class that's "supposed" to have the declarations of your page's
    controls isn't getting one, e.g. "protected Label lblFoo;"
    You can either supply one yourself by typing it in, or sometimes if you
    switch from design to code view and then back again, it gets itself "back
    together".
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "tofu.captain" wrote:

    > oops, actually what i have is that, i just wrong my example in this
    > topic wrong. but the issue still stands.
    >
    > so what i have is:
    > <asp:TextBox id="txtFoo" runat="server" />
    >
    > codebehind:
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > this.txtFoo.Text = "this works";
    > }
    >
    > sorry for the misprint.
    >
    > Chicagoboy27 wrote:
    > > try
    > >
    > > lblFoo.Text = "this works";
    > >
    > > txtFoo does not exist in your project.
    > >
    > >
    > > tofu.captain wrote:
    > > > I'm using Visual Studio .NET 2005 with a C# Web Application project. I
    > > > have an ASPX page that uses a MasterPage file for a general site
    > > > layout. That works just fine, but when I run a compile of the ASPX
    > > > page (say default.aspx) with something like:
    > > >
    > > > <asp:Label id="lblFoo" runat="server" />
    > > >
    > > > and have it's codebehind have:
    > > >
    > > > protected void Page_Load(object sender, EventArgs e)
    > > > {
    > > > this.txtFoo.Text = "this works";
    > > > }
    > > >
    > > > However, when I run a compile, the Error List reports that:
    > > > 'Default' does not contain a definition for 'txtFoo'
    > > >
    > > > when clearly there is. The problem is that the project compiles and
    > > > runs fine, but the error list is reporting an incorrect error. Does
    > > > anyone else have a similar problem with VS.NET 2005? Is this a bug in
    > > > the IDE?
    > > >
    > > > Some added notes:
    > > > - I do have multiple Default.aspx across my project, but they are in
    > > > different folders and I have checked that all referencing paths are
    > > > correct.
    > > > - I did copy & paste some code from a different page into this ASPX
    > > > page, and started noticing this bug, but I have commented out such code
    > > > and still get this problem running the above example. Is there a bug
    > > > with copying & pasting code from another ASPX page that runs something
    > > > similar to what I have above?
    > > >
    > > > Thanks so much

    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Dec 4, 2006
    #4
  5. tofu.captain

    tofu.captain Guest

    i actually did that and i get an error that the control is already
    declared. which, doesn't make sense...

    Peter wrote:
    > I think the issue here is that VS 2005 has the concept of partial classes.
    > The designer class that's "supposed" to have the declarations of your page's
    > controls isn't getting one, e.g. "protected Label lblFoo;"
    > You can either supply one yourself by typing it in, or sometimes if you
    > switch from design to code view and then back again, it gets itself "back
    > together".
    > Peter
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "tofu.captain" wrote:
    >
    > > oops, actually what i have is that, i just wrong my example in this
    > > topic wrong. but the issue still stands.
    > >
    > > so what i have is:
    > > <asp:TextBox id="txtFoo" runat="server" />
    > >
    > > codebehind:
    > > protected void Page_Load(object sender, EventArgs e)
    > > {
    > > this.txtFoo.Text = "this works";
    > > }
    > >
    > > sorry for the misprint.
    > >
    > > Chicagoboy27 wrote:
    > > > try
    > > >
    > > > lblFoo.Text = "this works";
    > > >
    > > > txtFoo does not exist in your project.
    > > >
    > > >
    > > > tofu.captain wrote:
    > > > > I'm using Visual Studio .NET 2005 with a C# Web Application project. I
    > > > > have an ASPX page that uses a MasterPage file for a general site
    > > > > layout. That works just fine, but when I run a compile of the ASPX
    > > > > page (say default.aspx) with something like:
    > > > >
    > > > > <asp:Label id="lblFoo" runat="server" />
    > > > >
    > > > > and have it's codebehind have:
    > > > >
    > > > > protected void Page_Load(object sender, EventArgs e)
    > > > > {
    > > > > this.txtFoo.Text = "this works";
    > > > > }
    > > > >
    > > > > However, when I run a compile, the Error List reports that:
    > > > > 'Default' does not contain a definition for 'txtFoo'
    > > > >
    > > > > when clearly there is. The problem is that the project compiles and
    > > > > runs fine, but the error list is reporting an incorrect error. Does
    > > > > anyone else have a similar problem with VS.NET 2005? Is this a bug in
    > > > > the IDE?
    > > > >
    > > > > Some added notes:
    > > > > - I do have multiple Default.aspx across my project, but they are in
    > > > > different folders and I have checked that all referencing paths are
    > > > > correct.
    > > > > - I did copy & paste some code from a different page into this ASPX
    > > > > page, and started noticing this bug, but I have commented out such code
    > > > > and still get this problem running the above example. Is there a bug
    > > > > with copying & pasting code from another ASPX page that runs something
    > > > > similar to what I have above?
    > > > >
    > > > > Thanks so much

    > >
    > >
    tofu.captain, Dec 5, 2006
    #5
  6. tofu.captain

    russmack

    Joined:
    Mar 12, 2007
    Messages:
    3
    Hi,

    I have exactly the same issue, causing quite a bit of trouble - did you manage to find a solution?

    Thanks.
    Russ


    russmack, Mar 12, 2007
    #6
  7. tofu.captain

    russmack

    Joined:
    Mar 12, 2007
    Messages:
    3
    Aarggh! At some point I made a "Copy of page.aspx", which resulted in a namespace or class name clash, which was reported as being in "page.aspx".
    Crikey.
    russmack, Mar 13, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh
    Replies:
    2
    Views:
    509
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  2. rockdale
    Replies:
    1
    Views:
    600
    Juan T. Llibre
    Aug 23, 2006
  3. hunkgym
    Replies:
    1
    Views:
    1,986
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 30, 2006
  4. xman
    Replies:
    0
    Views:
    487
  5. xman
    Replies:
    1
    Views:
    592
    Victor Bazarov
    Aug 17, 2005
Loading...

Share This Page