[英]changing themes with buttons, how?
我有 2 個要在現場使用的主題,它們位於主題文件夾-> 主題 1 和主題 2 中,在主題 1 和主題 2 中,我有一個 .css 文件。 那么我將如何將這些.css 文件連接到兩個按鈕,當我單擊 button1 時,我想要主題 1.css 激活並用於主題 2。 如果您需要有關問題的更多信息,請詢問。 謝謝
在 Page_PreInit 或之前插入代碼
{
this.Theme = "myTheme"
}
我在 asp.net 中創建了一個示例應用程序,看看這個,如果有任何疑問,請告訴我。
更新
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ProfilePage.aspx.cs" Inherits="ProfilePage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="test" Text="Stackoverflow" runat="server"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Theme1" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Theme2" OnClick="Button2_Click" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ProfilePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreInit(object sender, EventArgs e)
{
switch (Request.QueryString["theme"])
{
case "Blue":
Page.Theme = "Blue";
break;
case "Red":
Page.Theme = "Red";
break;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("ProfilePage.aspx?theme=Red");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("ProfilePage.aspx?theme=Blue");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.