protected void btnSubmit_Click(object Sender, EventArgs e) { String nick = this.txtNick.Text; String title = this.txtTitle.Text; String note = this.txtNote.Text; if (!GuestBook.Add(nick, title, note)) { this.lblMsg.Text = "留言失败"; } BindData(); }
public ActionResult Create(GuestEntry entry) { if (entry.Name == "Fido") { throw new InvalidOperationException("No dogs allowed"); } var book = new GuestBook(); book.Add(entry); return(RedirectToAction("List")); }