Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. /// <summary>
  2. /// Gets executed by the ExportButton OnClick event
  3. /// </summary>
  4. protected void ExportButtonClick(object sender, EventArgs e)
  5. {
  6. try
  7. {
  8. List<Item> childItemList = GetChildrenFromTargetItem(TargetTextBox.Text, SummaryLiteral);
  9. if (!childItemList.Any())
  10. {
  11. SummaryLiteral.Text = "No Child items for specified target item";
  12. return;
  13. }
  14.  
  15. ExportButton.Enabled = false;
  16. Response.Clear();
  17. Response.Buffer = true;
  18. Response.AddHeader("content-disposition", "attachment;filename=UserExport-" + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + ".csv");
  19. Response.Charset = "";
  20. Response.ContentType = "application/text";
  21. Response.Output.Write(GetCsv(childItemList));
  22. ExportButton.Enabled = true;
  23. SummaryLiteral.Text = "Successfully finished export.";
  24. Response.Flush();
  25. Response.End();
  26. }
  27. catch (System.Threading.ThreadAbortException)
  28. {
  29. // exception can be ignored
  30. }
  31. catch (Exception ex)
  32. {
  33. Response.Write(ex.ToString());
  34. SummaryLiteral.Text = "Error occured during export.";
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement