Nag Bandla
Nag Bandla

Reputation: 56

Make sure that the class defined in this code file matches the 'inherits' attribute,

Sometimes in my web applications I used to get this sort of error, I have no clue why is it coming however if I refresh the page few times the page is loading normally. enter image description here

I am using .net framework 2.0 and visual web developer 2005.

Upvotes: 1

Views: 2183

Answers (2)

ronenfe
ronenfe

Reputation: 2424

It happened to me when by accident I changed the codefile of another aspx file to point to the same code file as the current page file.

Make sure each aspx file point to the correct code file. Visual studio doesn't point you to the right file.

You can try and search the name of the file that causes the error to find the other page pointing to it.

Upvotes: 0

jgok222
jgok222

Reputation: 414

I have only ever seen this error message when the class that is contained in your file is diffrent from the class being called in the HTML page

For example at the top of your html page there will be a line of code that goes something like this:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="@whereyourcodeis.aspx.cs" Inherits="@ClassName" Title="whatever" %>

and in your whereyourcodeis.aspx.cs file there should be a constructor method that has the same name as the inherits line in your html. ie Class ClassName{ rest of your code}

If for some reason these two names do not match you get the error you have, hope this can shine some light on where your code is going wrong

Upvotes: 3

Related Questions