1
using System.IO;
2
3
public partial class BookWithThemes : System.Web.UI.MasterPage
4

{
5
/**//// <summary>
6
/// Upon loading,populate theme list based on themes in App_Themes folder
7
/// </summary>
8
protected void Page_Load(object sender, EventArgs e)
9
{
10
// dynamically load the drop down list only the first time
11
if (!IsPostBack)
12
{
13
// themes must be in this location
14
string path = Server.MapPath("~/App_Themes");
15
// verify this location exists
16
if (Directory.Exists(path))
17
{
18
// retrieve array of theme folder names
19
String[] themeFolders = Directory.GetDirectories(path);
20
// process each element in this array
21
foreach (String folder in themeFolders)
22
{
23
// retrieve information about this folder name
24
DirectoryInfo info = new DirectoryInfo(folder);
25
// add this folder name to the drop-down list
26
drpThemes.Items.Add(info.Name);
27
}
28
// once all the themes are added to the list, we must make the
29
// content page's current theme the selected item in the list
30
31
// first search the list items for the page's theme name
32
ListItem item = drpThemes.Items.FindByText(Page.Theme);
33
// now set the selected index of the list (i.e., select that
34
// list item) to the index of the list item we just found.
35
drpThemes.SelectedIndex = drpThemes.Items.IndexOf(item);
36
}
37
}
38
}
39
40
/**//// <summary>
41
/// Event handler for the theme selector
42
/// </summary>
43
protected void drpTheme_selectedChanged(object s, EventArgs e)
44
{
45
//save theme in session
46
string theme = drpThemes.SelectedItem.Text;
47
Session["themeName"] = theme;
48
49
//re-request page
50
string page = Request.Path;
51
Server.Transfer(page);
52
}
53
54
/**//// <summary>
55
/// Property to get/set the url of the advertisement image
56
/// </summary>
57
public string AdImageUrl
58
{
59
get
{ return imgbtnAd.ImageUrl; }
60
set
{ imgbtnAd.ImageUrl = value; }
61
}
62
63
/**//// <summary>
64
/// Property to get/set the url for the link surrounding the
65
/// advertisement image.
66
/// </summary>
67
public string AdNavigateUrl
68
{
69
get
{ return imgbtnAd.NavigateUrl; }
70
set
{ imgbtnAd.NavigateUrl = value; }
71
}
72
}
73

2

3

4



5


6

7

8

9



10

11

12



13

14

15

16

17



18

19

20

21

22



23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40


41

42

43

44



45

46

47

48

49

50

51

52

53

54


55

56

57

58



59



60



61

62

63


64

65

66

67

68



69



70



71

72

73
