Default1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs"
Inherits="Default1"%>
<!DOCTYPE html>
<html xmlns="http://www.198bona.com">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="https://www.csdn.net/">ASP.NET</a><br />
<br />
<a href="https://hao.360.com/">360瀏覽器</a>
<br />
<br />
<input id="Button1" type="button" value="button"/>
<br />
<br />
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="Theme1">Theme1</asp:ListItem>
<asp:ListItem Value="Theme2">Theme2</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:TextBox ID="TextBox2" runat="server" SkinID="textboxSkin"></asp:TextBox>
</div>
</form>
</body>
</html>
Default1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string url = Request.Path + "?theme=" + DropDownList1.SelectedItem.Value;
Response.Redirect(url);
}
void Page_PreInit(Object sender, EventArgs e)
{
string theme = "Theme1";
if (Request.QueryString["theme"] == null)
{
theme = "Theme1";
}
else
{
theme = Request.QueryString["theme"];
}
Page.Theme = theme;
ListItem item = DropDownList1.Items.FindByValue(theme);
if (item != null)
{
item.Selected = true;
}
}
}
if (Request.QueryString["theme"] == null)
{
theme = "Theme1";
//問題:設置theme="Theme1";顯示的就是主題Theme1,如果先設置了theme="Theme2",就顯示主題Theme2,不能和進行動態(tài)顯示。
}
else
{
theme = Request.QueryString["theme"];
}
以上深圳市博納網(wǎng)絡信息技術有限公司整理(www.sabong.net)
聯(lián)系客服