
Environment: ASP.NET AJAX Q2 2009 SP1 with VStudio SP1.
I am creating a site with Master->Detail Content pages (about 4). Currently in each Content Page code behind file Page_Prerender Event, it calls another Procedure ShowHideMasterMenu. Both are in the same code behind file. I am repeating the same below codes for all content pages because all does the exactly same thing.
My question is there any way I can put the codes of public void ShowHideMasterMenu() into a class library or into a Public Procedure and call it from all content pages Page_Prerender event? Below code (public void ShowHideMasterMenu() ) works but they are redundant and repeating codes for each content page.
Any help or pointing to right direction will be appreciated.
Sincerely
GC_0620
__________________________________________________________________________________________________________
protected void Page_Prerender(object sender, EventArgs e)
{
ShowHideMasterMenu();
}
public void ShowHideMasterMenu()
{
if (Session["SessionEmployeeId"] == null)
{
Response.Redirect("SessionExpired.aspx");
}
Panel masterUserDetailsPanel = (Panel)Master.FindControl("UserDetailsPanel");
masterUserDetailsPanel.Visible = true;
Label masterLoginLabel = (Label)Master.FindControl("LoginLabel");
masterLoginLabel.Text = Session["SessionUserFirstName"].ToString().Trim() + " " + Session["SessionUserLastName"].ToString().Trim();
RadMenu mastermenu = (RadMenu)Master.FindControl("RadMenu1");
mastermenu.FindItemByText("Login").Visible = false;
mastermenu.FindItemByText("Logout").Visible = true;
Label mpLabel = (Label)Master.FindControl("Lblislogged");
if (mpLabel != null)
{
mpLabel.Text = "1";
}
if ((Session["SessionUserEmplCategory"].ToString().Trim() == "User" | Session["SessionUserEmplCategory"].ToString().Trim() == "Manager") & Session["SessionUserIsAdmin"].ToString().Trim() == "False") //Regular (Manager or User)
{
mastermenu.Items.Remove(mastermenu.Items[0]);
mastermenu.Items.Remove(mastermenu.Items[1]);
}
else if (Session["SessionUserEmplCategory"].ToString().Trim() == "PR Manager" && Session["SessionUserIsAdmin"].ToString().Trim() == "False") //PR Manager
{
mastermenu.Items.Remove(mastermenu.Items[2]);
}
else if (Session["SessionUserEmplCategory"].ToString().Trim() == "PR Associate" && Session["SessionUserIsAdmin"].ToString().Trim() == "False") //PR Associate
{
mastermenu.Items.Remove(mastermenu.Items[2]);
mastermenu.Items[0].Items.RemoveAt(1);
}
else if (Session["SessionUserEmplCategory"].ToString().Trim() == "Manager" & Session["SessionUserIsAdmin"].ToString().Trim() == "True") //Admin
{
mastermenu.Items.Remove(mastermenu.Items[0]);
}
else
{
}
}
When writing a new post in the forums hereabouts, the "Attach your files" link is mis-placed in Opera v10 as is the list of attached files. See the attached screen shots.
--
Stuart