Пример #1
0
    protected void btnPost_Click(object sender, EventArgs e)
    {
        //check if post has required fields
        if ((txtTitle.Text != string.Empty) && (txtCategory.Text != string.Empty) && (txtPost.Text != string.Empty) && (txtSnippet.Text != string.Empty))
        {
            //publish the post
            db.CreateBlog(DateTime.Now, txtTitle.Text, txtSnippet.Text, txtPost.Text, txtCategory.Text, true, User.Identity.Name);
            Response.Redirect("~/User/Blog.cshtml");
        }

        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please fill in all required fields!')", true);
        }
    }