-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThemeManager.aspx.cs
38 lines (36 loc) · 1.25 KB
/
ThemeManager.aspx.cs
1
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Configuration;
public partial class ThemeManager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.User.Identity.IsAuthenticated)
{
Response.Redirect("~/LoginPlease.aspx");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");
//Get the required section of the web.config file by using configuration object.
PagesSection pages = (PagesSection)config.GetSection("system.web/pages");
//Update the new values.
pages.Theme = DropDownList1.SelectedItem.Text.ToString();
//save the changes by using Save() method of configuration object.
if (!pages.SectionInformation.IsLocked)
{
config.Save();
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('Could not save configuration')</script>");
}
}
}