protected void Page_Load(object sender, EventArgs e)
    {
        Session["EmailImgText"] = "none";
        Session["ProfileEdit"]  = "false";

        // Get the profile ID from the query string
        _personId = GetPersonFromQueryString();

        if (!IsPostBack)
        {
            if (_personId > 0)
            {
                personProfileList = new Connects.Profiles.Service.ServiceImplementation.ProfileService().GetPersonFromPersonId(_personId);

                personProfile = personProfileList.Person[0];

                if (personProfile != null)
                {
                    // check to see if profile is hidden
                    _isVisibleProfile = personProfile.Visible;


                    this.EditUserId = Profile.UserId;

                    // Handle situation where it's the logged-in user viewing their own page
                    ProcessSelfProxyAndHidden();

                    //Save Search History
                    if (Profile.UserId != 0)
                    {
                        SaveUserSearchHistory(_personId);
                    }

                    hypBack.NavigateUrl = (string)Session["BackPage"];
                    if ((string)Request["From"] == "SE")
                    {
                        hypBack.Visible = true;
                    }

                    // Set the page titles
                    Page.Title         = personProfile.Name.FirstName + " " + personProfile.Name.LastName + " | " + Page.Title;
                    ltProfileName.Text = personProfile.Name.FullName;

                    // Profiles OpenSocial Extension by UCSF
                    OpenSocialHelper os = SetOpenSocialHelper(Profile.UserId, _personId, Page);
                    os.SetPubsubData(OpenSocialHelper.JSON_PERSONID_CHANNEL, OpenSocialHelper.BuildJSONPersonIds(_personId, personProfile.Name.FullName));
                    // PMID
                    UserPreferences userPreference = new UserPreferences();
                    userPreference = _userBL.GetUserPreferences(_personId);
                    if (userPreference.Publications.Equals("Y"))
                    {
                        os.SetPubsubData(OpenSocialHelper.JSON_PMID_CHANNEL, OpenSocialHelper.BuildJSONPubMedIds(personProfile));
                    }
                    os.RemovePubsubGadgetsWithoutData();
                    GenerateOpensocialJavascipt();
                    pnlOpenSocialGadgets.Visible = OpenSocial().IsVisible();

                    // record that their profile was viewed
                    OpenSocialHelper.PostActivity(_personId, "profile was viewed");
                }
            }
        }

        InitializeUserControlEvents();
    }