protected void btn_add_Click(object sender, EventArgs e) { //create a new Forum objet, then pass it as a parameter in order to add post title to the database Forum post = new Forum(catID, TextBox1.Text, DateTime.Now, user.Id); DBconnection.addForumNewPost(post); post.Text = TextBox2.Text; post.PostID = DBconnection.lastPK("ID", "ForumPosts"); //add the message assosiated with this post DBconnection.addForumMessage(post); HttpContext.Current.Response.Write("<script>alert('Your post has been added')</script>"); //redirect the user to his message Response.Redirect("ForumMessages.aspx?catID=" + post.CategoryID + "&postID=" + post.PostID); }