WebButton.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Web;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using FastReport.Dialog;
  5. using System.Windows.Forms;
  6. namespace FastReport.Web
  7. {
  8. public partial class WebReport : WebControl, INamingContainer
  9. {
  10. private void ButtonClick(ButtonControl button)
  11. {
  12. if (button.DialogResult == DialogResult.OK)
  13. {
  14. FormClose(button, CloseReason.None);
  15. Prop.CurrentForm++;
  16. }
  17. else if (button.DialogResult == DialogResult.Cancel)
  18. {
  19. FormClose(button, CloseReason.UserClosing);
  20. Prop.State = ReportState.Canceled;
  21. }
  22. button.OnClick(null);
  23. }
  24. private void FormClose(ButtonControl button, CloseReason reason)
  25. {
  26. DialogPage dialog = button.Report.Pages[Prop.CurrentForm] as DialogPage;
  27. dialog.Form.DialogResult = button.DialogResult;
  28. FormClosingEventArgs closingArgs = new FormClosingEventArgs(reason, false);
  29. dialog.OnFormClosing(closingArgs);
  30. FormClosedEventArgs closedArgs = new FormClosedEventArgs(reason);
  31. dialog.OnFormClosed(closedArgs);
  32. dialog.ActiveInWeb = false;
  33. }
  34. private string GetButtonHtml(ButtonControl control)
  35. {
  36. return string.Format("<input class=\"{0}\" style=\"{1}\" type=\"button\" name=\"{2}\" value=\"{3}\" onclick=\"{4}\" title=\"{5}\" {6}/>",
  37. // class
  38. "",
  39. // style
  40. GetButtonStyle(control),
  41. // name
  42. control.Name,
  43. // value
  44. control.Text,
  45. // onclick
  46. GetEvent("onclick", control, ""),
  47. // title
  48. control.Text,
  49. // disabled
  50. control.Enabled ? "": "disabled"
  51. );
  52. }
  53. private string GetButtonStyle(ButtonControl control)
  54. {
  55. return string.Format("{0}{1}padding:0;margin:0;", GetStandardStyle(control), GetControlAlign(control));
  56. }
  57. }
  58. }