列出和选择Theme模版的代码

 1 None.gif using  System.IO;
 2 None.gif
 3 None.gif public  partial  class  BookWithThemes : System.Web.UI.MasterPage
 4 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 5ExpandedSubBlockStart.gifContractedSubBlock.gif   /**//// <summary>
 6InBlock.gif   /// Upon loading,populate theme list based on themes in App_Themes folder
 7ExpandedSubBlockEnd.gif   /// </summary>

 8InBlock.gif   protected void Page_Load(object sender, EventArgs e)
 9ExpandedSubBlockStart.gifContractedSubBlock.gif   dot.gif{
10InBlock.gif      // dynamically load the drop down list only the first time
11InBlock.gif      if (!IsPostBack)
12ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
13InBlock.gif         // themes must be in this location
14InBlock.gif         string path = Server.MapPath("~/App_Themes");
15InBlock.gif         // verify this location exists
16InBlock.gif         if (Directory.Exists(path))
17ExpandedSubBlockStart.gifContractedSubBlock.gif         dot.gif{
18InBlock.gif            // retrieve array of theme folder names
19InBlock.gif            String[] themeFolders = Directory.GetDirectories(path);
20InBlock.gif            // process each element in this array
21InBlock.gif            foreach (String folder in themeFolders)
22ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
23InBlock.gif               // retrieve information about this folder name
24InBlock.gif               DirectoryInfo info = new DirectoryInfo(folder);
25InBlock.gif               // add this folder name to the drop-down list
26InBlock.gif               drpThemes.Items.Add(info.Name);
27ExpandedSubBlockEnd.gif            }

28InBlock.gif            // once all the themes are added to the list, we must make the 
29InBlock.gif            // content page's current theme the selected item in the list
30InBlock.gif
31InBlock.gif            // first search the list items for the page's theme name
32InBlock.gif            ListItem item = drpThemes.Items.FindByText(Page.Theme);
33InBlock.gif            // now set the selected index of the list (i.e., select that 
34InBlock.gif            // list item) to the index of the list item we just found.
35InBlock.gif            drpThemes.SelectedIndex = drpThemes.Items.IndexOf(item);
36ExpandedSubBlockEnd.gif         }

37ExpandedSubBlockEnd.gif      }

38ExpandedSubBlockEnd.gif   }

39InBlock.gif
40ExpandedSubBlockStart.gifContractedSubBlock.gif   /**//// <summary>
41InBlock.gif   /// Event handler for the theme selector 
42ExpandedSubBlockEnd.gif   /// </summary>

43InBlock.gif   protected void drpTheme_selectedChanged(object s, EventArgs e)
44ExpandedSubBlockStart.gifContractedSubBlock.gif   dot.gif{
45InBlock.gif      //save theme in session        
46InBlock.gif      string theme = drpThemes.SelectedItem.Text;
47InBlock.gif      Session["themeName"= theme;
48InBlock.gif
49InBlock.gif      //re-request page
50InBlock.gif      string page = Request.Path;
51InBlock.gif      Server.Transfer(page);
52ExpandedSubBlockEnd.gif   }

53InBlock.gif
54ExpandedSubBlockStart.gifContractedSubBlock.gif   /**//// <summary>
55InBlock.gif   /// Property to get/set the url of the advertisement image
56ExpandedSubBlockEnd.gif   /// </summary>

57InBlock.gif   public string AdImageUrl
58ExpandedSubBlockStart.gifContractedSubBlock.gif   dot.gif{
59ExpandedSubBlockStart.gifContractedSubBlock.gif      get dot.gifreturn imgbtnAd.ImageUrl; }
60ExpandedSubBlockStart.gifContractedSubBlock.gif      set dot.gif{ imgbtnAd.ImageUrl = value; }
61ExpandedSubBlockEnd.gif   }

62InBlock.gif
63ExpandedSubBlockStart.gifContractedSubBlock.gif   /**//// <summary>
64InBlock.gif   /// Property to get/set the url for the link surrounding the 
65InBlock.gif   /// advertisement image.
66ExpandedSubBlockEnd.gif   /// </summary>

67InBlock.gif   public string AdNavigateUrl
68ExpandedSubBlockStart.gifContractedSubBlock.gif   dot.gif{
69ExpandedSubBlockStart.gifContractedSubBlock.gif      get dot.gifreturn imgbtnAd.NavigateUrl; }
70ExpandedSubBlockStart.gifContractedSubBlock.gif      set dot.gif{ imgbtnAd.NavigateUrl = value; }
71ExpandedSubBlockEnd.gif   }

72ExpandedBlockEnd.gif}

73 None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值