Dynamic Themes - style sheet
ِ
سلام...
اول بكم كه من تقريبا" تاز كارم و يه درد دلي بكنم بعد ميرم سر جواب سوال خودم ....
نمي دونم چرا بعضي از اساتيد اولا" بصورت گزينشي پاسخ بعضي از سوالات را ميدن ؟
ثانيا" سوال من خيلي سخت نبود ولي كسي مبادرت به پاسخش نكرد ..! شايد دليلش وجود چنين بحثي در سر فصل تدريس بعضي از آموزشگاها باشه ... البته شايد( و خوب باز شدن اون مبحث جذاب در يه forum آزاد ....)كلا" زماني سوال ها كمي جنبه تجاري(يا گاهآ حرفه اي ) پيدا كنه كسي زياد به اون جواب نمي ده ....
بي خيال .. به هر حال به راهي پيدا كردم البته زياد چنگي به ددل نمي زنه ولي خوب كار راه بندازه..
خوب اول يه پروژه web application باز مي كنيم و web.config اون را به صورت زير تغيير مي دهيم.
<?xml version="1.0"?>
<configuration>
<appSettings />
<connectionStrings />
<system.web >
<pages theme="a1">
</pages>
<anonymousIdentification enabled="true "/>
<profile>
<properties>
<add name ="fullname" defaultValue ="anonymous" allowAnonymous ="true" />
<add name="Mytheme" defaultValue ="a1" allowAnonymous ="true " />
</properties>
</profile>
</system.web>
</configuration>
حال درpage Default كنترلهاي image , label1 و
کد HTML:
<a href="wfSettings.aspx">wfSettings.aspx</a>
را قرار ميدهيم و در نهايت دستورات به شكل زير ميشود :
Default .aspx
کد HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebTBA2._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" >
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Label1.Text = Profile.fullname;
}
}
protected void Page_PreInit(object sender, EventArgs e)
{
Page.Theme = Profile.Mytheme;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Page1 </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Image ID="Image1" runat="server" />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<br /> <br />
welcom ... <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br /> <br />
<a href="wfSettings.aspx">wfSettings.aspx</a>
<br />
<br />
</div>
</form>
</body>
</html>
و يه page ديگر به نام wfSettings به پروژه اضافه مي كنيم ....
و page wfSettings.aspx هم به شكل زير مي شود :
کد HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfSettings.aspx.cs" Inherits="WebTBA2.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Profile.fullname = TextBox1.Text.ToString();
Profile.Mytheme = DropDownList1.SelectedValue;
Response.Redirect("Default.aspx");
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Text = Profile.fullname;
DropDownList1.Items.FindByValue(Profile.Mytheme).Selected = true;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
Enter full name :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br/><br/><br/><br/>
choose theme
<asp:DropDownList ID="DropDownList1" runat="server" Height="46px"
Width="73px" Font-Bold="True" Font-Size="Medium">
<asp:ListItem>a1</asp:ListItem>
<asp:ListItem>a2</asp:ListItem>
</asp:DropDownList>
<br/><br/>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="save"
Width="61px" />
</p>
</div>
</form>
</body>
</html>
و دو تا theme a1 , a2 هم يه پروژه اضافه مي كنيم .
در زير هم يه تمونه مثال هم گذاشتم ...
موفق باشيد .
------------------------------------------------------------------------------
در تاريخ 28 -05- 88 به روز شد.
تاپيك زير هم چند سوال و جواب پيرامون همين موضوع است .
http://www.barnamenevis.org/sh...d.php?t=174327