protected void btnInsert_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string Name = txtBookName.Text;
string Author = txtAuthor.Text;
string Publisher = txtPublisher.Text;
string Price = txtPrice.Text;
//save photo
string path = MapPath("~/Photos/");
string filename = Guid.NewGuid().ToString("N") + ".jpg";
SimpleImage img = new SimpleImage(fupPhoto.FileContent);
img.Square();
img.Resize(150);
img.SaveAs(path + filename);
Book b = new Book
{
name = Name,
author = Author,
publisher = Publisher,
price = Price,
photo = filename
};
db.Books.InsertOnSubmit(b);
db.SubmitChanges();
Response.Redirect("List.aspx");
}
}