母版使用Masterpages和继承 [英] MasterPage using Masterpages, and inheritance

查看:146
本文介绍了母版使用Masterpages和继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大师母版,和我有2亚健康Masterpages。这些潜艇2有自己的母版属性设置为主母版。所有好为止。

I've got a "Master" Masterpage, and I've got 2 "Sub" Masterpages. Those 2 subs have their masterpage property set to the "Master" Masterpage. All good so far.

好吧,我今天告诉也使Sub1的和分公司2实际上是继承从主母版。我以为他们是IM precise用自己的语言,但没有,她要我改变类定义

Well, I was told today to also make Sub1 and Sub2 actually "inherit" from the Master Masterpage. I thought they were being imprecise with their language, but no, she wanted me to change the Class definition to

public partial class Sub2 : TheMaster

(这些都不是名字)。

(those aren't the names).

所以,现在我已经得到了Sub1的和分公司2是母版页,并有世纪教主的母版页,而且他们是一流的世纪教主

So, now I've got Sub1 and Sub2 that are master pages, and have a master page of TheMaster, and ALSO they are of the class of "TheMaster"

我这个很困惑,不知道这会产生什么样的影响。这似乎编译和现在运行得很好,但我们才刚刚开始这6个月的项目的今天,我不想去每月5,找出我们有一个重大的设计缺陷。

I'm quite confused by this, and not sure what kinds of effects this will have. It seems to compile and run fine right now, but we are just starting this 6 month project today, and I don't want to get to month 5 and find out that we have a major design flaw.

谁能告诉我,这是完全罚款,或者说,我们完全搞砸了?

Can anyone tell me that this is totally fine, or that we are completely messed up?

我很害怕......抱着我。

I'm scared...hold me.

编辑:澄清 - 她希望我也从主母版页继承的原因是我们在该页面中设置一些东西,我们希望他们可以到子母版页。类似的事情在所呈现的页面是网站地图等等。

Clarification -- the reason she wanted me to also inherit from the master master page is that we set some things in that page, and we want them available to the sub master pages. Things like the current node in the sitemap that the rendered page is, some user account stuff, and much more.

推荐答案

基本上你所做的是设置的页面,这样的类继承所有从指定的基地项目。在母版属性的转播,将创建一个弱相关,并呈现特定的结构里面的内容。该类从基继承移动逻辑向前,到了而不是仅仅有它执行的方式,你可以覆盖它。

Basically what you have done is setup the page so that the class inherits all of the items from the specified base. The hookup of the "Masterpage" property, creates a weak association, and renders content inside of a specific structure. The class inheriting from the base moves the logic forward, into a manner where rather than just having it execute, you can override it.

现在,思考它后,你最有可能不希望母版属性集....只是类的继承

Now, after thinking about it, you most likely do not want the MasterPage property set....but just the class inheritance

这篇关于母版使用Masterpages和继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆