-
Notifications
You must be signed in to change notification settings - Fork 0
/
MasterPage.master.cs
48 lines (44 loc) · 1.74 KB
/
MasterPage.master.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
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI.WebControls;
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
List<page> pages = new List<page>();
if (Session["pages"] == null)
{
pages = page.getPages();
Session["pages"] = pages;
}
else
{
pages = (List<page>)Session["pages"];
}
getSubpages(pages[0], litPage0);
getSubpages(pages[1], litPage1);
getSubpages(pages[2], litPage2);
getSubpages(pages[3], litPage3);
getSubpages(pages[4], litPage4);
getSubpages(pages[5], litPage5);
}
public void getSubpages(page page, Literal litPage)
{
string queryString = HttpContext.Current.Request.Url.AbsolutePath;
litPage.Text = "";
foreach (subpage subpage in page._subpages)
{
string sub = Regex.Match(queryString, "/" + Regex.Replace(page._name, @"\s", "-") + "/" + Regex.Replace(subpage._name, @"\s", "-"), RegexOptions.IgnoreCase).ToString();
if (sub != "")
{
litPage.Text += "<li class='selected'><a href='/" + Regex.Replace(page._name, @"\s", "-").ToLower() + ".aspx/" + Regex.Replace(subpage._name, @"\s", "-").ToLower() + "'>" + subpage._name + "</a></li>";
}
else
{
litPage.Text += "<li><a href='/" + Regex.Replace(page._name, @"\s", "-").ToLower() + ".aspx/" + Regex.Replace(subpage._name, @"\s", "-").ToLower() + "'>" + subpage._name + "</a></li>";
}
}
}
}