/// <summary> /// Triggered when the user saves their haiku to the guestbook. /// Adds the haiku to the database and sets up the next screen layout. /// </summary> protected void btn_saveq_Click(object sender, EventArgs e) { // format user's initials if (text_initials.Text.Equals("Enter your initials") || String.IsNullOrEmpty(text_initials.Text)) { text_initials.Text = "Anonymous"; } else { text_initials.Text = text_initials.Text.ToUpper(); } // add haiku to db if (SaveHaiku(label_haiku1.Text, label_haiku2.Text, label_haiku3.Text, text_initials.Text)) { label_prompt.Text = "Saved!"; } else { label_prompt.Text = "Something went wrong. (I'm working on it)"; } // update guestbook text_initials.Visible = false; btn_saveq.Visible = false; DataList_gl.DataBind(); UpdatePanel1.Update(); }
/// <summary> /// Gets information about vote and passes information to UpdateVotes to process, then /// updates the guestbook with the new data. /// </summary> protected void votebtn_Click(object sender, EventArgs e) { using (Button b = (Button)sender) { string[] commandArgs = b.CommandArgument.ToString().Split(new char[] { ',' }); int id = Convert.ToInt32(commandArgs[0]); int votes = Convert.ToInt32(commandArgs[1]); if (b.CommandName == "upClick") { votes += 1; } else if (b.CommandName == "downClick") { votes -= 1; } // update db UpdateVotes(id, votes); // update guestbook DataList_gl.DataBind(); UpdatePanel1.Update(); } }