public partial class admin_series : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {    }
    string sqlConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    string path= "";
    string ImageName1 = "";
    string way = "";
    protected void Button4_Click(object sender, EventArgs e)
    {
        //RegisterStartupScript("id1", "<script>alert('123');</script>");
        //1.ScriptManager.RegisterStartupScript(Button2, this.GetType(), "button2", "alert('1111')", true);
        //2.ScriptManager.RegisterStartupScript(Button2, this.GetType(), "button2", "<script>alert('123');</script>", false);
        string type = "";
        if (this.FileUpload1.HasFile)//检查是否有文件
        {
            string fullFileName = this.FileUpload1.PostedFile.FileName;   //文件路径名
            //fileName = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1);   //图片名称
            type = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1);        //图片格式
            if (type == "jpg" || type == "JPG" || type == "gif" || type == "GIF" || type == "BMP" || type == "bmp") //判断是否为图片类型
            {
                if (this.FileUpload1.PostedFile.ContentLength > 500 * 1024)
                {
                    ScriptManager.RegisterStartupScript(Button4, this.GetType(), "button4", "alert('上传图片必须小于500k!');", true);
                }
                else
                {
                    //获取上传文件的网站目录路径
                    DateTime dt = DateTime.Now;
                    ImageName1 = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString() + "." + type;
                    path = HttpContext.Current.Request.MapPath("~/pic/" + ImageName1);
                    this.FileUpload1.SaveAs(path);//存储文件到磁盘
                    way = "~/pic/" + ImageName1;
                    // Response.Write("<script>alert('图片上传成功!');</script>");//提示
                    ScriptManager.RegisterStartupScript(Button4, this.GetType(), "button4", "alert('图片上传成功!');", true);
                    this.Image1.ImageUrl = way;//显示图片                }
            }
        }
        else
        {            ScriptManager.RegisterStartupScript(Button4, this.GetType(), "button4", "alert('" + type + "非图片类型,不允许上传!');", true);
        }
        this.TextBox2.Text = way;
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(sqlConnString);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "insert into series(series,typeid,pic,note) values(@series,@typeid,@pic,@note)";
        string series = TextBox1.Text;
        string typeid = "";
        if (DropDownList1.SelectedItem != null)
        {
            typeid = DropDownList1.SelectedValue;
        }
        string note = txtTitle.Text;
        string pic = TextBox2.Text;        cmd.Parameters.Add(new SqlParameter("@pic", pic));
        cmd.Parameters.Add(new SqlParameter("@series", series));
        cmd.Parameters.Add(new SqlParameter("@typeid", typeid));
        cmd.Parameters.Add(new SqlParameter("@note", note));
        cmd.Connection = con;
        con.Open();
        int sdr = cmd.ExecuteNonQuery();
        if (sdr == 0)
        {
            ScriptManager.RegisterStartupScript(Button3, this.GetType(), "button3", "alert('文件上传失败!');", true);
            if (this.TextBox1.Text == "")
            {
                ScriptManager.RegisterStartupScript(Button3, this.GetType(), "button3", "alert('请填写系列名称!');", true);
            }
            else if (this.txtTitle.Text == "")
            {
                ScriptManager.RegisterStartupScript(Button3, this.GetType(), "button3", "alert('请填写系列信息!');", true);
            }
            else if (this.FileUpload1.FileName == "")
            {
                ScriptManager.RegisterStartupScript(Button3, this.GetType(), "button3", "alert('请上传缩略图!');", true);
            }        }
        else
        {
            ScriptManager.RegisterStartupScript(Button3, this.GetType(), "button3", "alert('添加新系列成功!');", true);
        }
        con.Close();
    }
}
下面的条件没用啊,一点提交就显示 新系列添加成功
~~~帮帮忙