private void BtnCategoryClick(object sender, EventArgs e)
{
if (!Page.IsValid)
{
return;
}
var cat = new Category(txtCategory.Text, string.Empty);
cat.Save();
var item = new ListItem(Server.HtmlEncode(txtCategory.Text), cat.Id.ToString())
{
Selected = true
};
string catHtml = string.Format("<input type=\"checkbox\" id=\"{0}\">", cat.Id);
catHtml += string.Format("<label>{0}</label><br/>", Server.HtmlEncode(cat.Title));
cblCategories.InnerHtml += catHtml;
string postId = Request.QueryString["id"];
Post post = null;
// Security Rights validation
if (postId == null)
{
Security.DemandUserHasRight(Rights.CreateNewPosts, true);
post = new Post();
}
else
{
post = Post.GetPost(new Guid(postId));
if (post.CurrentUserOwns)
{
Security.DemandUserHasRight(Rights.EditOwnPosts, true);
}
else
{
Security.DemandUserHasRight(Rights.EditOtherUsersPosts, true);
}
}
}