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(); }
protected void Page_Load(object sender, EventArgs e) { if (!(HttpContext.Current.User.Identity.IsAuthenticated)) { FormsAuthentication.SignOut(); Session.Clear(); Response.Redirect("~/Default"); } currentlyLoggedUserName = HttpContext.Current.User.Identity.Name; currentlyLoggedUserID = Membership.GetUser(currentlyLoggedUserName).ProviderUserKey.ToString(); if (currentlyLoggedUserID == null) { Response.Redirect("~/Default"); } ListOFFreinds = new List <student22>(); this.friendIDList = new List <String>(); friendHld = new friendHandler(); //visitedUserId if (Session["id"] != null) { currentlyLoggedUserID = Session["id"].ToString(); } //visitedUserId if the mutual frienfs button is clicked if (Session["mutualClick"] != null) { visitedUserId = Session["mutualClick"].ToString(); friendIDList = friendHld.mutualFriends(currentlyLoggedUserID, visitedUserId); } else { friendIDList = friendHld.getFriendsList(currentlyLoggedUserID); } foreach (String friendID in friendIDList) { student22 myFriend = new student22(friendID, 0); ListOFFreinds.Add(myFriend); } createTable(); }
protected void Page_Load(object sender, EventArgs e) { if (!(HttpContext.Current.User.Identity.IsAuthenticated)) { FormsAuthentication.SignOut(); Session.Clear(); Response.Redirect("~/Default"); } currentlyLoggedUserName = HttpContext.Current.User.Identity.Name; currentlyLoggedUserID = Membership.GetUser(currentlyLoggedUserName).ProviderUserKey.ToString(); if (currentlyLoggedUserID == null) { Response.Redirect("~/Default"); } ListOFFreinds = new List<student22>(); this.friendIDList = new List<String>(); friendHld = new friendHandler(); //visitedUserId if (Session["id"] != null) { currentlyLoggedUserID = Session["id"].ToString(); } //visitedUserId if the mutual frienfs button is clicked if (Session["mutualClick"] != null) { visitedUserId = Session["mutualClick"].ToString(); friendIDList = friendHld.mutualFriends(currentlyLoggedUserID, visitedUserId); } else friendIDList = friendHld.getFriendsList(currentlyLoggedUserID); foreach (String friendID in friendIDList) { student22 myFriend = new student22(friendID, 0); ListOFFreinds.Add(myFriend); } createTable(); }
public List<student22> GetAllStudentsList() { DataTable allUserNameTable = userDb.getAllUsernames(); if (allUserNameTable.Rows.Count > 0) { foreach (DataRow dr in allUserNameTable.Rows) { String username = dr["UserName"].ToString(); student22 stud = new student22(username); this.allStudentsList.Add(stud); } } else { Console.WriteLine("No rows found."); } return this.allStudentsList; }
public List <student22> GetAllStudentsList() { DataTable allUserNameTable = userDb.getAllUsernames(); if (allUserNameTable.Rows.Count > 0) { foreach (DataRow dr in allUserNameTable.Rows) { String username = dr["UserName"].ToString(); student22 stud = new student22(username); this.allStudentsList.Add(stud); } } else { Console.WriteLine("No rows found."); } return(this.allStudentsList); }
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; } */ }
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(); }
}//end of class ReadMail private void createTable() { HtmlTable myTable = new HtmlTable(); myTable.Attributes["class"] = "table"; foreach (var msg in messageList) { String senderID = msg.SenderId; String recieverID = msg.RecieverId; String subject = msg.Subject; String body = Server.HtmlDecode(msg.Body); String datenTime = msg.Date.ToString(); //make sure to use the int constructor because that is the one that uses the UserID to make a student student22 thisStudent = new student22(senderID, 0); HtmlTableRow row = new HtmlTableRow(); //row.Attributes["class"] = "table"; if (senderID.Equals(currentlyLoggedUserID)) { row.Attributes["class"] = "alert alert-info"; } else { row.Attributes["class"] = "alert alert-warning"; } //////////////// cell1 userNameLabel /////////////////////////////////////////////// HtmlTableCell cell1 = new HtmlTableCell(); cell1.Attributes["class"] = "panel"; var userNameLabel = new Label(); userNameLabel.Text = thisStudent.getUsername(); //add the userNameLabel to cell1 cell1.Controls.Add(userNameLabel); //add cell1 to the row row.Controls.Add(cell1); //////////////// cell2 img /////////////////////////////////////////////// HtmlTableCell cell2 = new HtmlTableCell(); Image img = new Image(); img.Height = 60; img.Width = 60; img.Attributes["class"] = "media-object"; img.AlternateText = "No image on file"; img.ImageUrl = "ImageHandler.ashx?UserId=" + thisStudent.getStudent_id(); //add the btn to cell3 cell2.Controls.Add(img); //add cell3 to the row row.Controls.Add(cell2); //////////////// cell3 msgTextbox /////////////////////////////////////////////// HtmlTableCell cell3 = new HtmlTableCell(); var msgTextLabel = new Label(); msgTextLabel.Text = body; //add the msgTextbox to cell3 //if (senderID.Equals(currentlyLoggedUserID)) // cell3.Attributes["class"] = "alert alert-info"; //else // cell3.Attributes["class"] = "alert alert-warning"; cell3.Controls.Add(msgTextLabel); //add cell3 to the row row.Controls.Add(cell3); //////////////// cell4 dateTimeLabel /////////////////////////////////////////////// HtmlTableCell cell4 = new HtmlTableCell(); cell4.Attributes["class"] = ""; var dateTimeLabel = new Label(); dateTimeLabel.Text = datenTime; //add the userNameLabel to cell1 cell4.Controls.Add(dateTimeLabel); //add cell1 to the row row.Controls.Add(cell4); //add all rows to table myTable.Controls.Add(row); } //myTable.Attributes.Add("Class", "clsTradeInCart"); conversationLogPlaceHolder.Controls.Add(myTable); //PanelConversation.Attributes["class"] = "well"; PanelConversation.Height = 400; PanelConversation.Attributes["width"] = "auto"; }
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; * } */ }
private void createTable() { HtmlTable myTable = new HtmlTable(); myTable.Attributes["class"] = "table"; foreach (var msg in messageList) { String senderID = msg.SenderId; String recieverID = msg.RecieverId; String subject = msg.Subject; String body = Server.HtmlDecode(msg.Body); String datenTime = msg.Date.ToString(); //make sure to use the int constructor because that is the one that uses the UserID to make a student student22 thisStudent = new student22(senderID, 0); HtmlTableRow row = new HtmlTableRow(); //row.Attributes["class"] = "table"; if (senderID.Equals(currentlyLoggedUserID)) row.Attributes["class"] = "alert alert-info"; else row.Attributes["class"] = "alert alert-warning"; //////////////// cell1 userNameLabel /////////////////////////////////////////////// HtmlTableCell cell1 = new HtmlTableCell(); cell1.Attributes["class"] = "panel"; var userNameLabel = new Label(); userNameLabel.Text = thisStudent.getUsername(); //add the userNameLabel to cell1 cell1.Controls.Add(userNameLabel); //add cell1 to the row row.Controls.Add(cell1); //////////////// cell2 img /////////////////////////////////////////////// HtmlTableCell cell2 = new HtmlTableCell(); Image img = new Image(); img.Height = 60; img.Width = 60; img.Attributes["class"] = "media-object"; img.AlternateText = "No image on file"; img.ImageUrl = "ImageHandler.ashx?UserId=" + thisStudent.getStudent_id(); //add the btn to cell3 cell2.Controls.Add(img); //add cell3 to the row row.Controls.Add(cell2); //////////////// cell3 msgTextbox /////////////////////////////////////////////// HtmlTableCell cell3 = new HtmlTableCell(); var msgTextLabel = new Label(); msgTextLabel.Text = body; //add the msgTextbox to cell3 //if (senderID.Equals(currentlyLoggedUserID)) // cell3.Attributes["class"] = "alert alert-info"; //else // cell3.Attributes["class"] = "alert alert-warning"; cell3.Controls.Add(msgTextLabel); //add cell3 to the row row.Controls.Add(cell3); //////////////// cell4 dateTimeLabel /////////////////////////////////////////////// HtmlTableCell cell4 = new HtmlTableCell(); cell4.Attributes["class"] = ""; var dateTimeLabel = new Label(); dateTimeLabel.Text = datenTime; //add the userNameLabel to cell1 cell4.Controls.Add(dateTimeLabel); //add cell1 to the row row.Controls.Add(cell4); //add all rows to table myTable.Controls.Add(row); } //myTable.Attributes.Add("Class", "clsTradeInCart"); conversationLogPlaceHolder.Controls.Add(myTable); //PanelConversation.Attributes["class"] = "well"; PanelConversation.Height = 400; PanelConversation.Attributes["width"] = "auto"; }