protected void cmdSubmit_Click(Object sender, EventArgs e) { // Create a new BookEntry object. BookEntry newEntry = new BookEntry(); newEntry.Author = txtName.Text; newEntry.Submitted = DateTime.Now; newEntry.Message = txtMessage.Text; // Let the SaveEntry procedure create the corresponding file. try { SaveEntry(newEntry); } catch (Exception err) { // An error occurred. Notify the user and don't clear the // display. lblError.Text = err.Message + " File not saved."; return; } // Refresh the display. GuestBookList.DataSource = GetAllEntries(); GuestBookList.DataBind(); txtName.Text = ""; txtMessage.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { guestBookName = Server.MapPath("GuestBook"); if (!this.IsPostBack) { GuestBookList.DataSource = GetAllEntries(); GuestBookList.DataBind(); } }