一个是具有导航条的NavBar.ascx,两个页面存在一个相同的函数,判断用户是否登录,然后做出不同的显示


1
// properties
2
public bool hidecategorymenu = false;
3
4
private void Page_Load(object sender, System.EventArgs e)
5
{
6
// Put user code to initialize the page here
7
//ShowMenuArea();
8
ShowLoggedInArea();
9
}
10
11
// display different items if person is logged in or not
12
private void ShowLoggedInArea() {
13
14
if (Request.IsAuthenticated != true) {
15
16
areaLoggedIn.Visible = false;
17
areaLoggedOut.Visible = true;
18
19
} else {
20
21
areaLoggedIn.Visible = true;
22
areaLoggedOut.Visible = false;
23
24
}
25
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

最后还有一个静态的SignOutNavBar.ascx用户控件.当用户登出的时候显示这个用户控件