Articles → .NET → Giving Identity To Each Page In ASP.NET 2.0
Giving Identity To Each Page In ASP.NET 2.0
- First of all create a website and name them say "WebSite1".
- Add 2 pages Default1.aspx and Default2.aspx in the project.
- Make the pages added above as content pages i.e. add a property MasterPageFile in the page directives of both files and add in both the pages.
public enum MenuType {
Admin,
NonAdmin
}
private MenuType _MenuObject;
public MenuType MenuObject {
get {
return _MenuObject;
}
set {
_MenuObject = value;
}
}
if (!IsPostBack) {
((MasterPage) Page.Master).MenuObject = MasterPage.MenuType.NonAdmin;
}
if (!IsPostBack) {
((MasterPage) Page.Master).MenuObject = MasterPage.MenuType.Admin;
}
if (_MenuObject == MenuType.Admin) {
// Create a menu for Admin
}
else if (_MenuObject == MenuType.NonAdmin) {
// Create a menu for Non Admin
}