在主页c#中使用特定条件动态设置主题 [英] set the themes dynamically with certain condition in master page c#

查看:116
本文介绍了在主页c#中使用特定条件动态设置主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ...





我的App_themes中有3个主题。主题将设置或在我的母版(源代码)调用

<链接HREF = ../ App_Themes文件/ FCRSThemes /主题/ theme2.css 的rel = stylesheettype =text / css/> 





我想在web配置文件中设置一个值,即..

< add key =Themevalue =1/> 





基于web配置中的键值,我想在母版页中设置主题..



我该怎么做?并希望代码写在master page.cs ....任何想法..?

解决方案

你可以创建3个不同主题的母版页并动态加载它们在特定页面上的条件如下。



在特定页面上动态设置母版页。



'预郎=CS> <跨度类=代码关键字>保护 <跨度类=代码关键字>空隙 Page_PreInit(<跨度类=代码关键字 >对象发​​件人,EventArgs e)
{
如果(您的条件)
{
.MasterPageFile = <跨度类= 代码串> <跨度类= 代码串 > MasterPage.master;
}
其他 {

}

}







欲了解更多信息:在运行时为特定页面选择母版页


heyy...


I have 3 themes in my App_themes . The theme will set or call in my masterpage(source code) .

<link href="../App_Themes/FCRSThemes/theme/theme2.css" rel="stylesheet" type="text/css" />



I want to set a value in web config file ie..

<add key="Theme" value="1" />



based on the key value in web config, I want set the theme in master page..

How can I do this ? and want code to write in master page.cs.... Any idea..?

解决方案

You can create 3 master pages with different themes and load them dynamically according to your condition on particular page is as below.

Set the master page dynamically on specific page.

protected void Page_PreInit(object sender, EventArgs e)
{
    if (your condition)
{
    this.MasterPageFile = "MasterPage.master";
}
else{

}

}




For more info :select master page at run time for a specific page


这篇关于在主页c#中使用特定条件动态设置主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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