protected void btnDone_Click(object sender, EventArgs e) { // Get the item to which this PDF is related int itemID; String itemIDString = Request.QueryString["ItemID"] as String; List<int> pageIDs = new List<int>(); // Get the page numbers being requested foreach (DataListItem dlItem in dlPages.Items) { HtmlInputCheckBox pageCheckbox = (HtmlInputCheckBox)dlItem.FindControl("chkPage"); if (pageCheckbox.Checked) pageIDs.Add(Int32.Parse(pageCheckbox.Value)); } String shareWith = txtShareWith.Text; String articleTitle = txtArticleTitle.Text; String articleCreators = txtAuthors.Text; String articleTags = txtSubjects.Text; String emailAddress = txtEmail.Text; bool imagesOnly = rdoImages.Checked; if (shareWith.StartsWith("Enter email addresses")) shareWith = String.Empty; if (articleCreators.StartsWith("Enter names")) articleCreators = String.Empty; if (articleTags.StartsWith("Enter subjects")) articleTags = String.Empty; // Validate submitted data if (this.ValidatePage(itemIDString, pageIDs, emailAddress, shareWith, out itemID)) { litError.Text = this._errMsg; // Save submitted data BHLProvider provider = new BHLProvider(); MOBOT.BHL.DataObjects.PDF pdf = provider.AddNewPdf(itemID, emailAddress, shareWith, imagesOnly, articleTitle, articleCreators, articleTags, pageIDs); this.SendEmail(emailAddress, pdf.PdfID); Response.Cookies["pdf"]["id"] = pdf.PdfID.ToString(); Response.Cookies["pdf"].Expires = DateTime.Now.AddDays(1); Response.Redirect("/PdfGenDone.aspx"); } else { // Return and give error message to user litError.Text = this._errMsg; } }