コード例 #1
0
        protected void Button_UpdateNews_Click(object sender, EventArgs e)
        {
            User loggedUser = Help.GetUserSession(Session);

            if (loggedUser != null && editingPost != null && loggedUser.ID == editingPost.Creator.ID)
            { //If there is a logged in user, and a post being editted, and the person logged in created the post...
                editingPost.Data = FreeTextBox1.ViewStateText;
                bool result = DatabaseHandler.UpdateNewsPost(Session, editingPost);
                if (result)
                {
                    ShowNewsInfo("News post successfully updated!", Color.Green);
                }
                else
                {
                    ShowNewsInfo("Error occured while trying to update the news post.", Color.Red);
                }
            }
            else
            {
                if (editingPost == null)
                {
                    ShowNewsInfo("This is not a post yet, press Submit New instead.", Color.Red);
                }
            }
        }