开发者

Problem with Master Page and Virtual Path Provider

开发者 https://www.devze.com 2022-12-20 06:56 出处:网络
I built a deployable master page into a dll and referenced it in multiple ASP.NET Web Applications using a virtual path provider. The problem开发者_StackOverflow中文版 I\'m having is that this really

I built a deployable master page into a dll and referenced it in multiple ASP.NET Web Applications using a virtual path provider. The problem开发者_StackOverflow中文版 I'm having is that this really confuses the source view of my aspx pages.

Here is the code inside each of my aspx.cs pages which actually attatches the MasterPage to each content page, but as I said, now, my <asp:Content> tags get really confused and I cant CTRL K + CTRL + D my content pages anymore, it throws validation errors on EVERYTHING. HELP!

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


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.

0

精彩评论

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

关注公众号