Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

i have one master page file which calls user control page (AdminleftNav.ascx) filr from code behind.
but the page_load event firing first time in ascx file.
if i refresh the page, it does n't firing.
here is my admin code behind code:
C#
if (HttpRuntime.Cache.Get("LeftNavigation_" + loggedUser.UserId.ToString()) == null)
                   {
                       HttpRuntime.Cache.Insert("LeftNavigation_" + loggedUser.UserId.ToString(), Page.LoadControl("AdminLeftNav.ascx"), null, DateTime.Now.AddMinutes(1000), System.Web.Caching.Cache.NoSlidingExpiration);
                   }
                   var userControl = (UserControl)HttpRuntime.Cache.Get("LeftNavigation_" + loggedUser.UserId.ToString());
                   phLeftNav.Controls.Add(userControl);



my page_load function code is :
C#
protected void Page_Load(object sender, EventArgs e)
        {
            var loggedUser = CommonFunctions.GetLoggedUser();

            if (!IsPostBack)
            {
                try
                {
                    if (loggedUser != null)
                    {
                        companyId = (int)loggedUser.CompanyId;

                        var company = _companyService.Single(x => x.CompanyId == companyId);

                        if (company != null)
                            imgCompanyLogo.ImageUrl = "../images/companylogo/" + company.CompanyLogoPath;

                        var NewVacancies = _jobService.Find(x => x.JobStatusId == 1 || x.JobStatusId == 6).Count();

                        if (NewVacancies > 0)
                        {
                            phJobWaitingForApproval.Visible = true;
                            phNoJobWaitingForApproval.Visible = false;
                        }
                    }

                }
                catch (Exception ex)
                {
                    _log.Log(ex);
                }
            }
        }
Posted

1 solution

Hi,
i have found solution for my problem.

in user control page, within constructor add the following line.

this.Load+=Page_Load;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900