Пример #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        paneInfo.Visible = panelAttention.Visible = panelError.Visible = panelSuccess.Visible = false;
        lbAttention.Text = lbError.Text = lbInfo.Text = lbSuccess.Text = "";
        if (txtTitle.Text.Trim() == "" || Textarea1.Value.Trim() == "")
        {
            panelAttention.Visible = true;
            lbAttention.Text       = "标题或者文章内容不可为空!";
        }
        else
        {
            Entity.Articles arc = new Entity.Articles();
            arc.setClassID(int.Parse(ddlArticleClass.SelectedValue.ToString()));
            arc.setTitle(txtTitle.Text);
            arc.setKeyWords(txtKeyWords.Text);
            arc.setDesription(txtDescription.Text);
            arc.setContents(Textarea1.Value.Trim());
            arc.setPubDate(DateTime.Now.ToString());
            arc.setViewTimes(1);
            arc.setAuthor("admin");

            if (article.InsertArticle(arc) > 0)
            {
                panelSuccess.Visible = true;
                lbSuccess.Text       = "新增成功!";
                txtDescription.Text  = txtKeyWords.Text = txtTitle.Text = Textarea1.Value = "";
            }
            else
            {
                panelError.Visible = true;
                lbError.Text       = "添加失败!";
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        paneInfo.Visible = panelAttention.Visible = panelError.Visible = panelSuccess.Visible = false;
        lbAttention.Text = lbError.Text = lbInfo.Text = lbSuccess.Text = "";
        if (txtTitle.Text.Trim() == "" || Textarea1.Value.Trim() == "")
        {
            panelAttention.Visible = true;
            lbAttention.Text = "标题或者文章内容不可为空!";
        }
        else
        {
            Entity.Articles arc = new Entity.Articles();
            arc.setClassID(int.Parse(ddlArticleClass.SelectedValue.ToString()));
            arc.setTitle(txtTitle.Text);
            arc.setKeyWords(txtKeyWords.Text);
            arc.setDesription(txtDescription.Text); 
            arc.setContents(Textarea1.Value.Trim());
            arc.setPubDate(DateTime.Now.ToString());
            arc.setViewTimes(1);
            arc.setAuthor("admin");

            if (article.InsertArticle(arc) > 0) 
            {
                panelSuccess.Visible = true;
                lbSuccess.Text = "新增成功!";
                txtDescription.Text =   txtKeyWords.Text =  txtTitle.Text =  Textarea1.Value = "";
            }
            else
            {
                panelError.Visible = true;
                lbError.Text = "添加失败!";
            }
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
       Entity.Articles arc = article.GetArtcleObjByAID(int.Parse(Request["AID"].ToString()));
        Page.Header.Title = arc.getTitle()+"_"+arc.getClassName();  
        List<HtmlMeta> listMeta = seo.AllMeta(arc.getKeyWords(), arc.getDesription());
        HtmlHead head = (HtmlHead)Page.Header;
        head.Controls.Add(listMeta[0]);
        head.Controls.Add(listMeta[1]);   

        formContent.DataSource = article.GetArtcleByAID(int.Parse(Request["AID"].ToString()));
        formContent.DataBind();
    }