如何在.Net中的多个母版页中调用代码块? [英] How can I have a code block called across multiple master pages in .Net?

查看:106
本文介绍了如何在.Net中的多个母版页中调用代码块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!



我有一个包含7个不同母版页的网站。但是每个母版页都有相同的逻辑菜单。因此,我需要为所有7个母版页上的菜单设置相同的代码块。



如果我通过在所有7个母版页上复制相同的代码块来实现这一点,如果菜单中需要更改,我需要编辑菜单7次。



为了解决这个问题,我开始使用我可以在主人之外定义的用户控件页面,然后调用所有母版页。



这对我很有用,但我的开发团队负责人不断提出过度加重系统负担的问题使用像用户控件这样的东西,这完全不是为了这种用法而做的,因而未经过长期影响。



这里有没有人有更好的解决方案,或者是否可以安全地假设用户控件是前进之路?



为了让您了解我如何实现我的母版页,您可以在此查看我的帖子:

[ ^ ]



如果需要请告诉我提供更多细节。



非常感谢!

解决方案

嵌套母版页

http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx [ ^ ]

Hello!

I have a site with 7 different master pages. But every master page has the same "logic" for the menu. Thus I need to have the same code block for the menu on all 7 master pages.

If I implement this by copying the same code block on all 7 master pages, I will need to edit the menu 7 times if there is any change needed in the menu.

To fix this I started using User Controls that I could define outside the master pages, and then call on all the master pages.

This is working great for me, but my development team lead keeps bringing up the issue of over burdening the system by using something like User Controls which is totally not made for this kind of usage, and thus untested for its long term implications.

Does anyone here have a better solution, or is it safe to assume that User Controls is the way forward?

To give you a sense of how I am implementing my master pages you can review my post here:
[^]

Do let me know if I need to provide any more details.

Thanks a ton!

解决方案

Nested Master Page
http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx[^]


这篇关于如何在.Net中的多个母版页中调用代码块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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