开发者

Why the difference in how Inherits works in the WebForm?

开发者 https://www.devze.com 2023-03-10 08:06 出处:网络
I stumbled on something that surprised me.I\'m migrating a couple of WebForms from a common web project into two different web projects.The projects are treating the Inherits tag (in the source / HTML

I stumbled on something that surprised me. I'm migrating a couple of WebForms from a common web project into two different web projects. The projects are treating the Inherits tag (in the source / HTML view) differently.

Take this example: SomeWonderfulPage.aspx / SomeWonderfulPage.aspx.cs

The code-behind is totally standard (and no namespa开发者_如何学Goce):

public partial class SomeWonderfulPage : System.Web.UI.Page 
{
  //...
}

In one project Inherits="SomeWonderfulPage" works and Inherits="MyNameSpace.Blah.SomeWonderfulPage" fails (intellisense can't see the Label controls, and the project won't build); and in the other project it's the other way around.

I confirmed the behavior by making new WebForms in both projects via the 'Add New Item...' command in VS2008 - same results.

Does anyone know why this is?


When I copied the web pages from the first site (into which I had refactored the webforms) into the second site the SomeWonderfulPage.designer.cs files came across but weren't included in the project by default.

In such cases I found (on further exploration) that I couldn't get either Inherit to work.

Including the designer files fixed it. Doh.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号