Categories
ASP.NET

Make sure that the class defined in this code file and "inherits" attributes match,And which extends the base class(Such as Page or UserControl)is correct。

One problem encountered in a recent lecture over to them is an error at compile time asp.net "Make sure that the code defined in the class file and" inherits "attribute matches,And which extends the base class(Such as Page or UserControl)is correct。”

 

Was so amazing even encountered an error,That is the whole sample pages Copy the code can be executed,Copy the individually control error,error,Nature is more than a mistake。

From the Internet for answers,Probably there are two cases,I am fromHerefor reference

 

1.aspx page inherits the name and the code aspx.cs different class nameCause (usually because the two pages which have modified a page,Or copy all other page code)

2.You may add their own name-spacebetween,Compile normal after removing,But I hope to join a namespace,Solutions:After ASPX page inherits added namespacename,For example, the original inherits =”index”,Namespace category,Now replaced inherits =”category.index”.

 

Later, I was probably in line with the first case it,The exact terms is really the first case,But here there are a knowledge,I'm hereHereI found this focus,I posted it down:

Although the ASPX page case insensitive,But @page directive inherits be case sensitive,To correspond codeFile specified aspx.cs page class,Consistent case

 

I briefly summarized below,IDE generated automatically inherits the field contents are not case sensitive,Because aspx page does not distinguish,But in the @page directive is to distinguish,So many times the question was out of negligence。In short,Whether or not case sensitive,We should develop a clear case of good habits:)

Original article written by Gerber drop-off:R0uter's Blog » Make sure that the class defined in this code file and "inherits" attributes match,And which extends the base class(Such as Page or UserControl)is correct。

Reproduced Please keep the source and description link:https://www.logcg.com/archives/291.html

By R0uter's Blog

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *