if ((txtTitle.Text) == "" && (ftb_Content.Text) == "")
{
Response.Write("<script language='javascript'>alert('新闻标题或内容不能为空!')</script>");
}
else
{
string fullfileName = this.FileUpload1.PostedFile.FileName;
string imgname = FileUpload1.PostedFile.FileName.Substring(fullfileName.LastIndexOf("\\") + 1);
string filePath = Server.MapPath("~/admin/upImage/" + imgname);
string time = DateTime.Now.ToString();
if (FileUpload1.PostedFile != null)
{
this.FileUpload1.PostedFile.SaveAs(filePath);
}
string sql = "insert into xgb_news_content(news_Title,news_Content,news_Click,news_Img,newsType_ID,newsDtime) values('" + txtTitle.Text.ToString() + "','" + ftb_Content.Text.ToString() + "',0,'" + imgname.ToString() + "',1,'" + time.ToString() + "')";
DB.insert(sql);//DB为我后台编辑的一个类,用来执行sql语句
Response.Write("<script language='javascript'>alert('新闻发表成功!')</script>");
}