2009-03-04 78 views
0

有什么方法可以根据网站使用的主题使用特定的usercontrols?基于主题的用户控件asp.net

场景: 我在我的asp.net项目中使用主题。我将有相同的代码库和不同的外观和感觉,所以使用主题&皮肤。 现在的问题是,如果我想根据网站的类型使用不同的页眉&页脚(这是usercontrols),我们如何在主题的帮助下做到这一点。

回答

0

是的,控制层次结构可以用主题修改。

这使得ITemplate属性是具有标题性的

如果,例如,你有那只是有一个主题化内容自定义控件属性,你可以说:

<custom:MyThemeableControl runat="server"> 
    <Contents> 
    ... any valid *.skin markup here 
    </Contents> 
</custom:MyThemeableControl> 

现在你可以换出控制内部内容为不同的主题如下: - 对ThemeA你将有以下皮肤:

<custom:MyThemeableControl runat="server"> 
    <Contents> 
     <asp:Button runnat="server" /> 
    </Contents> 
</custom:MyThemeableControl> 

而对于ThemeB你将有FOL降脂皮肤:

<custom:MyThemeableControl runat="server"> 
    <Contents> 
     <asp:TextBox runnat="server" /> 
    </Contents> 
</custom:MyThemeableControl> 

接着这个页面会呈现按钮ThemeA文本框ThemeB

<@Page Theme="ThemeA"> 
<custom:MyThemeableControl runat="server" /> 

<@Page Theme="ThemeB"> 
<custom:MyThemeableControl runat="server" />