Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(HttpContext.Current.User.Identity.IsAuthenticated))
        {

            FormsAuthentication.SignOut();
            Session.Clear();
            Response.Redirect("~/Default.aspx");
        }
        currentUserName = HttpContext.Current.User.Identity.Name;
        UserId = Membership.GetUser(currentUserName).ProviderUserKey.ToString();

        if (UserId == null)
        {
            Response.Redirect("~/Default");
        }

        //if (!IsPostBack)   //if this is the first time the page is loading
        currentStudent = new student22(currentUserName);

        Label2.Visible = false;

        //  if (!IsPostBack) you actually want it to get data every time the page is loaded
        //so comment the postback method instead

        //get information about the currently logged in student
        Image1.ImageUrl = "ImageHandler.ashx?UserId=" + UserId;
        studentName = currentStudent.getActualName();
        majorName = currentStudent.getMajor();
        AboutYourselve = currentStudent.getAboutMe();

        //set labels in front end
        studentNameLabel.Text = studentName;
        usernameLabel.Text = currentUserName;
        majorNameLabel.Text = majorName;

        if (!IsPostBack)   //if this is the first time the page is loading
            aboutMeBox.Text = AboutYourselve;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //get all major names in the major table and add them to the drop down menu called majorsDropDown
        if (!IsPostBack)
        {
            majors majorsObject = new majors();

            majorsList = majorsObject.getMajorsList();

            majorsDropDown.Items.Clear();
            majorsDropDown.Items.Insert(0, new ListItem("Select Major", ""));

            foreach (String theMajorName in majorsList)
            {
                majorsDropDown.Items.Add(theMajorName);
            }

        }//end of if (!IsPostBack)
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //Image.ImageUrl= currentStudent.getProfilePic();
    }
Ejemplo n.º 2
0
    protected void Update_Click(object sender, EventArgs e)
    {
        upload2();

        String newName          = actualNameBox.Text;
        String newSelectedMajor = majorsDropDown.SelectedItem.Value;
        String aboutMe          = aboutMeBox.Text;

        currentStudent.setStudentAttributes(newName, newSelectedMajor, aboutMe);

        studentNameLabel.Text = currentStudent.getActualName();

        majorNameLabel.Text = currentStudent.getMajor();

        aboutMeBox.Text = currentStudent.getAboutMe();


        //reset boxes and dropdown menu
        actualNameBox.Text = string.Empty;
        majorsDropDown.ClearSelection();


        //Response.Redirect(Request.RawUrl);
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(HttpContext.Current.User.Identity.IsAuthenticated))
        {
            FormsAuthentication.SignOut();
            Session.Clear();
            Response.Redirect("~/Default.aspx");
        }
        currentUserName = HttpContext.Current.User.Identity.Name;
        UserId          = Membership.GetUser(currentUserName).ProviderUserKey.ToString();


        if (UserId == null)
        {
            Response.Redirect("~/Default");
        }


        //if (!IsPostBack)   //if this is the first time the page is loading
        currentStudent = new student22(currentUserName);

        Label2.Visible = false;

        //  if (!IsPostBack) you actually want it to get data every time the page is loaded
        //so comment the postback method instead


        //get information about the currently logged in student
        Image1.ImageUrl = "ImageHandler.ashx?UserId=" + UserId;
        studentName     = currentStudent.getActualName();
        majorName       = currentStudent.getMajor();
        AboutYourselve  = currentStudent.getAboutMe();


        //set labels in front end
        studentNameLabel.Text = studentName;
        usernameLabel.Text    = currentUserName;
        majorNameLabel.Text   = majorName;

        if (!IsPostBack)   //if this is the first time the page is loading
        {
            aboutMeBox.Text = AboutYourselve;
        }



        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //get all major names in the major table and add them to the drop down menu called majorsDropDown
        if (!IsPostBack)
        {
            majors majorsObject = new majors();

            majorsList = majorsObject.getMajorsList();

            majorsDropDown.Items.Clear();
            majorsDropDown.Items.Insert(0, new ListItem("Select Major", ""));

            foreach (String theMajorName in majorsList)
            {
                majorsDropDown.Items.Add(theMajorName);
            }
        }//end of if (!IsPostBack)
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Image.ImageUrl= currentStudent.getProfilePic();
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(HttpContext.Current.User.Identity.IsAuthenticated))
        {
            FormsAuthentication.SignOut();
            Session.Clear();
            Response.Redirect("~/Default");
        }
        //getting information about currently logged in user
        currentlyLoggedUserName = HttpContext.Current.User.Identity.Name;
        currentlyLoggedUserID   = Membership.GetUser(currentlyLoggedUserName).ProviderUserKey.ToString();

        if (currentlyLoggedUserID == null)
        {
            Response.Redirect("~/Default");
        }

        //recieve a username from another page (from
        visitedUserName = "";
        if (Session["name"] != null)
        {
            visitedUserName = Session["name"].ToString();
            visitedStudent  = new student22(visitedUserName);
            visitedUserId   = visitedStudent.getStudent_id();
        }
        else
        {
            Response.Redirect("~/Default");
        }

        friendHld = new friendHandler();

        if (currentlyLoggedUserName.Equals(visitedUserName))
        {
            btnFriends.Text         = "Your friends";
            btnMutalFriends.Visible = false;
            btnAddFriend.Visible    = false;
        }
        else
        {
            btnFriends.Text = visitedUserName + "'s friends";

            numOfMutualFriends   = friendHld.getNumberOfMutualFriends(currentlyLoggedUserID, visitedUserId);
            btnMutalFriends.Text = "" + numOfMutualFriends + " Mutual friends";
            //check to see if they are friends or not
            //btnAddFriend.Text = "Unfriend" if they are;
            areTheyFriends();
        }


        //for debugging
        System.Diagnostics.Debug.WriteLine("userName is = " + visitedUserName);



        Image1.ImageUrl = "ImageHandler.ashx?UserId=" + visitedUserId;
        //get information about the currently logged in student
        studentName    = visitedStudent.getActualName();
        majorName      = visitedStudent.getMajor();
        AboutYourselve = visitedStudent.getAboutMe();


        //set labels in front end
        studentNameLabel.Text = studentName;
        usernameLabel.Text    = visitedUserName;
        majorNameLabel.Text   = majorName;
        //summaryLabelBox.Text = AboutYourselve;

        summaryLabel.Text = AboutYourselve;


        //make the h3 tag change dynamically when the page is loaded to reflect change in username
        messageh3.InnerText = "Send a message to: " + visitedUserName;

        //dynamically change the width if

        /*
         * int charRows = 0;
         * string tbCOntent;
         * int chars = 0;
         * tbCOntent = AboutYourselve;
         * summaryLabelBox.Columns = 60;
         * chars = tbCOntent.Length;
         * charRows = chars / summaryLabelBox.Columns;
         * int remaining = chars - charRows * summaryLabelBox.Columns;
         * if (remaining == 0)
         * {
         *  summaryLabelBox.Rows = charRows;
         *  summaryLabelBox.TextMode = TextBoxMode.MultiLine;
         * }
         * else
         * {
         *  summaryLabelBox.Rows = charRows + 1;
         *  summaryLabelBox.TextMode = TextBoxMode.MultiLine;
         * }
         */
    }