|
using System;
using System.Collections;
using System.Web.Security;
using ASPNET.StarterKit.TimeTracker.BusinessLogicLayer;
namespace ASPNET.StarterKit.TimeTracker.Web
{
// UserControl that contains the top logo as well as the main navigation tabs
public abstract class Banner : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.LinkButton LogOff;
protected System.Web.UI.WebControls.DataList tabs;
private void Page_Load(object sender, System.EventArgs e)
{
ArrayList tabItems = new ArrayList();
if (Request.IsAuthenticated)
// add the Log tab (all users can see this tab)
tabItems.Add(new TabItem("Log", "TimeEntry.aspx?index=" + tabItems.Count));
// Show log off button if user is form authenticated
if (Context.User.Identity.AuthenticationType == "Forms")
LogOff.Visible = true;
if (TTSecurity.IsInRole(TTUser.UserRoleAdminPMgr))
{
tabItems.Add(new TabItem("Reports", "Reports.aspx?index=" + tabItems.Count));
tabItems.Add(new TabItem("Administration", "ProjectList.aspx?index=" + tabItems.Count));
}
tabs.DataSource = tabItems;
tabs.SelectedIndex = (Request["index"]==null) ? 0 : Convert.ToInt32(Request["index"]);
tabs.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.LogOff.Click += new System.EventHandler(this.LogOff_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LogOff_Click(object sender, System.EventArgs e)
{
FormsAuthentication.SignOut();
// Invalidate roles token
Response.Cookies["userroles"].Value = "";
Response.Cookies["userroles"].Path = "/";
Response.Cookies["userroles"].Expires = new System.DateTime(1999, 10, 12);
Context.User = null;
Response.Redirect("Default.aspx", false);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here