如何在运行时应用主题? [英] how to apply themes at runtime?
问题描述
用户想要通过单击给定的选项(例如greentheme,redtheme等)来更改主题.我该如何实现呢?
user want to change theme by clicking on a given options Like greentheme,redtheme etc. how can i implement this?
推荐答案
这很容易用Google搜索.如果您用谷歌在运行时更改主题",则第一个结果将在此站点上出现: ^ ],它会回答您的问题.
请先用Google搜索您的问题.
This is very easily googled. If you google "change themes at runtime" the first result is on this very site: How to change page theme in asp.net 2.0 dynamically at runtime[^] and it answers your question.
Please google your question first.
我发现此链接非常有用:
http://www.codeproject.com/Articles/18300/How-to-change-page-theme-in-asp-net-2-0-dynamicall
我添加了主题:在我的项目中为白色,黄色和红色.
添加主题:
I find this link vey useful :
http://www.codeproject.com/Articles/18300/How-to-change-page-theme-in-asp-net-2-0-dynamicall
I added themes : As White , Yellow and Red In my Project .
To add theme :
<asp:button runat="server" xmlns:asp="#unknown">
BackColor="White"
ForeColor="Black"
Font-Name="Times New Roman"
Font-Size="12px" />
<asp:button runat="server">
BackColor="Red"
ForeColor="Green"
Font-Name="Arial Black"
Font-Size="12px" />
<asp:button runat="server">
BackColor="Yellow"
ForeColor="Orange"
Font-Name="Comic Sans MS"
Font-Size="12px" />
</asp:button></asp:button></asp:button>
我已经为黄色"和红色"主题选择了两个按钮,并为显示消息"添加了一个标签.代码如下
I have taken two buttons for Yellow and Red Theme and a label to Display message . Code is as below
<pre lang="HTML">
<asp:button id="btnYellowTheme" runat="server" text="Yellow Theme" style="position :absolute ; left: 76px; top: 74px;" onclick="btnYellowTheme_Click" xmlns:asp="#unknown" />
<asp:button id="btnRedTheme" runat="server" text="Red Theme" style="position :absolute ; left: 225px; top: 74px;" height="24px" onclick="btnRedTheme_Click" xmlns:asp="#unknown" />
<asp:label id="lblDisplay" runat="server" text="" style="position :absolute; left: 135px; top: 34px;" xmlns:asp="#unknown"></asp:label>
对于Coding Part,要动态应用主题:
For Coding Part , to apply theme dynamically :
public partial class _Default : System.Web.UI.Page
{
string thmName;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreInit(Object sender, EventArgs e)
{
thmName = (string)Session["ThemeName"];
if (thmName != null)
{
Page.Theme = thmName;
lblDisplay.Text = "You have applied Theme :" + (string)Session ["ThemeName"];
}
else
{
thmName = "White";
Page.Theme = thmName;
lblDisplay.Text = "This is default White Theme";
}
}
protected void btnYellowTheme_Click(object sender, EventArgs e)
{
thmName = "Yellow";
Session["ThemeName"] = thmName;
Session["ThemeName"] = "Yellow";
Server.Transfer(Request.FilePath);
}
protected void btnRedTheme_Click(object sender, EventArgs e)
{
thmName = "Red";
Session["ThemeName"] = thmName;
Response.Redirect("Default.aspx");
Session["ThemeName"] = "Red";
Server.Transfer(Request.FilePath);
}
}
<pre lang="text">
Thank You
查看此链接将为您提供帮助
http://www.dotnetstuff.co.cc/2012/01/theame- settings-in-aspnet.html [ ^ ]
see this link it will help you
http://www.dotnetstuff.co.cc/2012/01/theame-settings-in-aspnet.html[^]
这篇关于如何在运行时应用主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!