2

我在 dll 中构建了一个可部署的母版页,并使用虚拟路径提供程序在多个 ASP.NET Web 应用程序中引用它。我遇到的问题是,这真的混淆了我的 aspx 页面的源视图。

这是我每个 aspx.cs 页面中的代码,它实际上将 MasterPage 附加到每个内容页面,但正如我所说,现在,我的<asp:Content>标签变得非常混乱,我不能再按 CTRL K + CTRL + D 我的内容页面了,它抛出一切的验证错误。帮助!

protected override void OnPreInit(EventArgs e)
        {
            MasterPageFile = MasterPageVirtualPathProvider.MasterPageFileLocation;
            base.OnPreInit(e);
        }
4

1 回答 1

2

To get design time support for shared MP you need to provide markup for VS to work with.

You can do this by copying your MP's markup file in you consuming project, removing the codebehind attribute and delete the codebehind file OR add a linked copy with a blank codebehind.

Now set your content page's masterpage to the stub you just created and you should have design time support.

Your VPP should render from the embedded markup at runtime.

Not optimal but if you want design-time support I think this is the only way.

于 2010-02-17T22:03:21.200 回答