protected void BulletedListPostOptions_Click(object sender, BulletedListEventArgs e) { BLPost blPost = new BLPost(); BulletedList options = sender as BulletedList; RepeaterItem item = options.Parent as RepeaterItem; Topic topic = GetTopic(int.Parse(HiddenFieldTopicId.Value)); Post post = blPost.GetPostById(int.Parse((item.FindControl("HiddenFieldPostId") as HiddenField).Value)); switch (options.Items[e.Index].Text.ToLowerInvariant()) { case "quote": { Reply(topic, post); break; } case "delete": { blPost.Delete(post); Response.Redirect(Request.RawUrl); break; } default: { Response.Redirect(options.Items[e.Index].Value); break; } } }
protected void ButtonSubmit_Click(object sender, EventArgs e) { // moet dit zo ophalen ivm datacontext BLPost blPost = new BLPost(); Post post = blPost.GetPostById(GetPostFromQueryString().Id); string content = TextBoxContent.Text; ParseQuotes(ref content); post.Content = content; blPost.Update(); Response.Redirect("~/ViewTopic.aspx?id=" + post.Topic.Id); }
protected Post GetPostFromQueryString() { int postId; if (!int.TryParse(Request.QueryString["id"], out postId)) { throw new HttpException(400, "Bad Request"); } Post post = new BLPost().GetPostById(postId); if (post == null) { throw new HttpException(404, "Not Found"); } return(post); }