public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if(System.Web.HttpContext.Current.User.Identity.Name != "") //if (!Page.IsPostBack)
{
BusinessLayer.ShoppingCart cart = new BusinessLayer.ShoppingCart();
int count = cart.getNoOfProducts(System.Web.HttpContext.Current.User.Identity.Name);
Label lblCart = (Label)Master.FindControl("lblCartNo");
lblCart.Text = " (" + count + ")";
}
}
}
I placed a breakpoint and this code is never called (even without the if statement), also I was not able to find the label which is located in the master page
In order for Page_Load to be called, make sure that in your MasterPage.aspx have AutoEventWireup=”true”:
Make sure that MasterPage.aspx Inherits attribute matches your code-behind namespace and class name, as well as your .designer.cs namespace and class.
If the aspx and code-behind files all are wired up correctly, then you should be able to remove the FindControl statement.