protected void Page_Load(object sender, EventArgs e)
    {
        fillNames();
        if (!AppLib.IsLoggedinSessionExists())
            Response.Redirect(AppConfig.GetBaseSiteUrl() + "Welcome/Main_Frame.aspx", true);
        MembershipUser currentUser = Membership.GetUser();
        Roles.GetRolesForUser(HttpContext.Current.User.Identity.Name);
        //string strScript = "<script type='text/javascript'>function load(sUrl) { document.getElementById(iframeName).src = '" + AppConfig.GetBaseSiteUrl() + "' + sUrl; } </script>";
        //this.Page.RegisterClientScriptBlock("abc", strScript);
        objBackofficeClass = new BackofficeClass(objSqlConnClass.OpenConnection());
        objForumClass = new ForumClass(objSqlConnClass.sqlConnection);

        BackofficeClass objBackOfficeClass;
        objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection());
        DataSet DS = objBackOfficeClass.Mem_GET_Admin(currentUser.UserName);
        if (DS != null)
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                if (DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("Administrator"))
                {
                    if (Session["popup"] != null)
                    {
                        bool pop = (bool)Session["popup"];

                        if (pop)
                        {
                            BLL.CompanyManager oCompanyManager = new BLL.CompanyManager();
                            int no = oCompanyManager.GetQuestion();
                            // string Script = "jConfirm('You have " + no + " unanswered HealthCoach Message !  Click Ok to answer them', 'HealthCoach Message',function(r) {alert(r);});";

                            if (no != 0)
                            {

                                string Script = "jConfirm('You have " + no + " unanswered HealthCoach Message !  Click Ok to see them', 'HealthCoach Message',function(r) { if(r) {window.location.href = '../Backoffice/UserUtilities/ManageQuestionforHealthCoach.aspx';}});";
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseWindow", Script, true);
                                Session["popup"] = false;
                                Response.Redirect("../Backoffice/UserUtilities/ManageQuestionforHealthCoach.aspx");
                            }
                        }
                        else
                        {
                            Session.Remove(Session["popup"].ToString());
                        }
                    }
                    else
                    {

                    }
                }

                else
                {
                    if (Session["popup"] != null)
                    {
                        bool pop = (bool)Session["popup"];

                        if (pop)
                        {
                            BLL.CompanyManager oCompanyManagers = new BLL.CompanyManager();
                            int no = oCompanyManagers.GetAnswers(currentUser.UserName);
                            if (no != 0)
                            {
                                string Script = "jConfirm('You have " + no + " answered HealthCoach Message !  Click Ok to see them', 'HealthCoach Message',function(r) { if(r) {window.location.href = '../Users/MyAskedQuestions.aspx';}});";
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseWindow", Script, true);
                                Session["popup"] = false;
                            }
                        }
                        else
                        {
                            Session.Remove(Session["popup"].ToString());
                        }
                    }
                    else
                    {

                    }
                }
            }
        }

        //if (Request.QueryString["register"] != null)
        //{
        //    IFRAME_CONTENT.Attributes.Remove("src");
        //    IFRAME_CONTENT.Attributes.Add("src", "UserUtilities/CreateUser.aspx");
        //}

        //if (!IsPostBack)
        {
            fillOutForm();
        }

        //if (HttpContext.Current.User.IsInRole("Administrator"))
        //{

        //    if (Session["popup"] != null)
        //    {
        //        bool pop = (bool)Session["popup"];

        //        if (pop)
        //        {
        //            BLL.CompanyManager oCompanyManager = new BLL.CompanyManager();
        //            int no = oCompanyManager.GetQuestion();
        //            string Script = "jConfirm('You have " + no + " unanswered HealthCoach Message !  Click Ok to answer them', 'HealthCoach Message',function(r) { if(r) {window.location.href = '../Backoffice/UserUtilities/ManageQuestionforHealthCoach.aspx';}});";
        //            ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseWindow", Script, true);
        //            Session["popup"] = false;
        //        }
        //        else
        //        {
        //            Session.Remove(Session["popup"].ToString());
        //        }
        //    }
        //    else
        //    {

        //    }
        //}
        //else
        //{

        //}
    }
    private void fillNames()
    {
        string usr = "";
        try
        {
            MembershipUser currentUsers = Membership.GetUser();
            BackofficeClass objBackOfficeClass;
            objBackOfficeClass = new BackofficeClass(objSqlConnClass.OpenConnection());
            DataSet DS = objBackOfficeClass.Mem_GET_Admin(currentUsers.UserName);
            if (DS != null)
            {
                if (DS.Tables[0].Rows.Count > 0)
                {
                    usr = DS.Tables[0].Rows[0]["ROLENAME"].ToString().Equals("User").ToString();
                    if (usr == "True")
                    {
                        usr = "******";
                    }
                }
            }

            lblName.Text = "Guest";

            lblLogout.Text = "<a style='text-decoration: underline;color:white;' href='" + AppConfig.GetBaseSiteUrl() + "login/logout.aspx'>Logout</a>";
            if (Membership.GetUser() != null)
            { //lblEdit.Text = "<a class='small' href=\"javascript:load('/main/UserUtilities/EditUser.aspx');\">My Account</a> <span style=font-weight:normal;>|</span> ";
                lblEdit.Text = "<a style='color:white; Font:inherit;'   href=\"" + AppConfig.GetBaseSiteUrl() + "BackOffice/UserUtilities/UserAccount.aspx?src=" + usr + "\">My Account</a> <span style=font-weight:normal;></span> ";
                /* Above line is commented by Netsmartz*/
                //lblLogout.Text = "<a class='small' href='/login/logout.aspx'>Logout</a>"; /*Commented By Netsmartz*/
                lblLogout.Text = "<a style='text-decoration: underline;color:white;' href='" + AppConfig.GetBaseSiteUrl() + "login/logout.aspx'>Logout</a>";

                string sUsername = Membership.GetUser().UserName;
                DS = objBackofficeClass.Mem_GET_UserInfo(sUsername);
                if (DS != null)
                    lblName.Text = DS.Tables[0].Rows[0]["FNAME"].ToString() + " " + DS.Tables[0].Rows[0]["LNAME"].ToString();

            }
        }
        catch { }
    }