protected void AddActorButton_Click(object sender, EventArgs e) { string firstName = FirstNameTextBox.Text.Trim(); string lastName = LastNameTextBox.Text.Trim(); if (firstName != "" && lastName != "") { int country = int.Parse(CountriesDropDownList.SelectedValue); int bYear = int.Parse(BornYearTextBox.Text.Trim()); string pic = ""; if (PhotoFileUpload.PostedFile != null) { if (PhotoFileUpload.PostedFile.FileName.Trim().Length > 0 && PhotoFileUpload.PostedFile.ContentLength > 0) { pic = Path.GetFileName(PhotoFileUpload.PostedFile.FileName.Trim()); string dir = Server.MapPath("~/Pictures/Actors/"); string file = Path.GetFileName(PhotoFileUpload.PostedFile.FileName.Trim()); PhotoFileUpload.PostedFile.SaveAs(dir + file); } } Actor a1 = new Actor(0, firstName, lastName, bYear, country, pic); Actors.AddActor(a1); int actorID = Actors.GetLastActorID(); Response.Redirect("/Pages/OneActor.aspx?aid=" + actorID); } }