private void displayPosts(List <Forum> p) { catID = Int32.Parse(Request.QueryString["catID"]); for (int i = 0; i < p.Count; i++) { HtmlTableRow tr = new HtmlTableRow(); ForumCategoriesTable.Controls.Add(tr); HtmlTableCell td_IMG = new HtmlTableCell(); HtmlGenericControl img = new HtmlGenericControl("img"); img.Attributes.Add("src", "images/forumPosts.png"); td_IMG.Controls.Add(img); HtmlTableCell td_title = new HtmlTableCell(); HtmlGenericControl a = new HtmlGenericControl("a"); a.Attributes.Add("href", "ForumMessages.aspx?catID=" + p[i].CategoryID + "&postID=" + p[i].PostID); a.InnerHtml = p[i].Title + " <br />"; td_title.Controls.Add(a); HtmlGenericControl span = new HtmlGenericControl("span"); span.Attributes.Add("class", "desc"); User user = DBconnection.getUser(p[i].UserID); span.InnerText = user.Name; td_title.Controls.Add(span); HtmlTableCell td_Messages = new HtmlTableCell(); td_Messages.InnerHtml = DBconnection.getNumberOfRecords("PostID_FK", p[i].PostID) + " Messages"; tr.Controls.Add(td_IMG); tr.Controls.Add(td_title); tr.Controls.Add(td_Messages); } }
private void displayMessages(List <Forum> m) { for (int i = 0; i < m.Count; i++) { HtmlTableRow tr = new HtmlTableRow(); ForumTableMessages.Controls.Add(tr); HtmlTableCell td_UserInfo = new HtmlTableCell(); tr.Controls.Add(td_UserInfo); HtmlGenericControl ul = new HtmlGenericControl("ul"); td_UserInfo.Controls.Add(ul); HtmlGenericControl li1 = new HtmlGenericControl("li"); user = DBconnection.getUser(m[i].UserID); li1.InnerText = user.Name; ul.Controls.Add(li1); HtmlGenericControl li2 = new HtmlGenericControl("li"); li2.InnerText = user.Experience; ul.Controls.Add(li2); HtmlTableCell td_Message = new HtmlTableCell(); tr.Controls.Add(td_Message); HtmlGenericControl p = new HtmlGenericControl("p"); p.InnerHtml = m[i].Text; td_Message.Controls.Add(p); HtmlGenericControl div = new HtmlGenericControl("div"); div.InnerText = m[i].Date.ToString(); td_Message.Controls.Add(div); } }
protected void btn_login_Click(object sender, EventArgs e) { string loginEmail = txt_email.Text; string loginPassword = txt_password.Text; string confirmPassword = DBconnection.getPassword(loginEmail); if (loginPassword.Equals(confirmPassword)) { Session["loginData"] = DBconnection.getUser(loginEmail); Response.Write("<script>alert('You are logged in')</script>"); Response.Redirect(Request.Url.ToString()); } else { Response.Write("<script>alert('Details do not match.')</script>"); } }
private void displaySessions(List <Class> s) { Random random = new Random(); //if there are no classes in the database show error message if (s.Count == 0) { //create a generic html control (paragraph <p>) HtmlGenericControl error = new HtmlGenericControl("p"); //insert the content of a paragraph (<p>CONTENT</p>) error.InnerHtml = "<h2>Unfortunately, we do not have any sessions on selected day"; //add the html control to a div container with an ID of "extraThing" :) extraThing.Controls.Add(error); } else { for (int i = 0; i < s.Count; i++) { //create a HTML table row using HTML controlls and add it to //the table with ID of "sessionTable" HtmlTableRow tr = new HtmlTableRow(); sessionsTable.Controls.Add(tr); //create a table cell/column HtmlTableCell td1 = new HtmlTableCell(); //add this table cell to a table row tr.Controls.Add(td1); //create a generic <img> html tag HtmlGenericControl img = new HtmlGenericControl("img"); //give src attribute to the img tag and assign a path to it //this path contains a random number that randomly chooses image for each session img.Attributes.Add("src", "images/" + random.Next(1, 6) + ".jpg"); //add image to the table cell td1.Controls.Add(img); //tile & description column HtmlTableCell td2 = new HtmlTableCell(); tr.Controls.Add(td2); HtmlGenericControl title = new HtmlGenericControl("a"); title.InnerHtml = "<h2>" + s[i].Title + "</h2>"; //pass the session type and session ID to querry string //querry string with these information will be used on ReservationPage.aspx page title.Attributes.Add("href", "ReservationPage.aspx?id=" + s[i].Id + "&type2=Class"); td2.Controls.Add(title); HtmlGenericControl description = new HtmlGenericControl("p"); description.InnerText = s[i].Description; td2.Controls.Add(description); //Additional information column HtmlTableCell td3 = new HtmlTableCell(); tr.Controls.Add(td3); //create a html unordered list and populate it with list elements HtmlGenericControl ul = new HtmlGenericControl("ul"); td3.Controls.Add(ul); HtmlGenericControl li1 = new HtmlGenericControl("li"); //date and time ul.Controls.Add(li1); li1.InnerText = s[i].StartDate.ToShortDateString() + " at " + s[i].Time.ToString(@"hh\:mm"); HtmlGenericControl li2 = new HtmlGenericControl("li"); //level ul.Controls.Add(li2); li2.InnerText = s[i].Level; HtmlGenericControl li3 = new HtmlGenericControl("li"); //duration ul.Controls.Add(li3); li3.InnerText = "Duration: " + s[i].Duration.ToString() + " min"; HtmlGenericControl li4 = new HtmlGenericControl("li"); //available spaces ul.Controls.Add(li4); li4.InnerText = "Available: " + (s[i].Capacity - s[i].Reservations).ToString(); HtmlGenericControl li5 = new HtmlGenericControl("li"); //sessions status ul.Controls.Add(li5); li5.InnerText = s[i].Status; HtmlGenericControl li6 = new HtmlGenericControl("li"); ul.Controls.Add(li6); li6.InnerText = "With " + DBconnection.getUser(s[i].InstructorID).Name; //book column //contains a link to ReservationPage with parameters for querry string HtmlTableCell book = new HtmlTableCell(); tr.Controls.Add(book); HtmlGenericControl link = new HtmlGenericControl("a"); if (s[i].Status.Equals("Cancelled")) { book.Controls.Add(link); link.Attributes.Add("class", "bookLink"); link.Attributes.Add("href", "#"); link.InnerText = "Session cancelled"; } else { book.Controls.Add(link); link.Attributes.Add("class", "bookLink"); link.Attributes.Add("href", "ReservationPage.aspx?id=" + s[i].Id + "&type2=Class"); link.InnerText = "Book"; } } } }