protected void btnConfirmar_Click(object sender, EventArgs e) { clsAutor autor = new clsAutor(); autor.Nome = Request.Form["txtNome"]; autor.Origem = Request.Form["txtOrigem"]; if (autor.Nome == "" || autor.Origem == "" || fileFoto.HasFile == false) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "modalMessage('Aviso', 'Preencha todos os campos!!');", true); } else if (fileFoto.HasFile == true || autor.Nome != "" || autor.Origem != "") { string caminhoServer = Server.MapPath("~/IMAGENS/AUTORES/"); string imgFile = Path.GetFileName(fileFoto.PostedFile.FileName); string caminho = Path.Combine(caminhoServer, imgFile); fileFoto.SaveAs(caminho); autor.Foto = imgFile; Autores autores = new Autores(); autores.Inserir(autor); autor.Nome = ""; autor.Origem = ""; Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Cadastro Realizado');window.location.href='Autor.aspx';", true); } }