protected void AddNews_Click(object sender, EventArgs e) { News news = new News(); news.News_Title1 = txtTitle.Text.Trim(); news.News_Time1 = DateTime.Now; news.News_Conentent1 = txtContent.Text; news.News_Num1 = int.Parse(txtNum.Text.Trim()); news.News_Img1 = @"~/Img_News/" + FileUpload1.PostedFile.FileName; news.News_Class1 = DropDownList_Class.SelectedItem.Text; try { if (NewsBll.Addnews(news) == 1) { txtContent.Text = ""; txtTitle.Text = ""; txtNum.Text = ""; Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('添加成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } }