WebTextBox.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using FastReport.Dialog;
  2. using System.Web;
  3. using System.Web.UI;
  4. using System.Web.UI.WebControls;
  5. namespace FastReport.Web
  6. {
  7. public partial class WebReport : WebControl, INamingContainer
  8. {
  9. private void TextBoxChange(TextBoxControl tb, string data)
  10. {
  11. tb.Text = data;
  12. tb.FilterData();
  13. tb.OnTextChanged(null);
  14. }
  15. private string GetValHook()
  16. {
  17. return
  18. "<script>$.valHooks.textarea = {" +
  19. "get: function(elem) {" +
  20. "return elem.value.replace(/\\r?\\n/g, \'\\r\\n\');" +
  21. "}};</script>";
  22. }
  23. private string GetTextBoxHtml(TextBoxControl control)
  24. {
  25. string id = Prop.ControlID + control.Name;
  26. if (control.Multiline)
  27. {
  28. return
  29. GetValHook() +
  30. string.Format("<textarea class=\"{0}\" style=\"{1}\" type=\"text\" name=\"{2}\" onchange=\"{4}\" id=\"{5}\" maxlength=\"{6}\" {7}>{3}</textarea>",
  31. // class
  32. "", //0
  33. // style
  34. GetTextBoxStyle(control), //1
  35. // name
  36. control.Name, //2
  37. // value
  38. control.Text, //3
  39. // onclick
  40. GetEvent("onchange", control, string.Format("$('#{0}').val()", id)), //4
  41. //GetEvent("onchange", control, string.Format("document.getElementById('{0}').value", id)), //4
  42. // title
  43. id, //5
  44. control.MaxLength,
  45. control.Enabled ? "" : "disabled"
  46. );
  47. }
  48. else
  49. {
  50. return string.Format("<input class=\"{0}\" style=\"{1}\" type=\"text\" name=\"{2}\" value=\"{3}\" onchange=\"{4}\" id=\"{5}\" maxlength=\"{6}\" {7}/>",
  51. // class
  52. "",
  53. // style
  54. GetTextBoxStyle(control),
  55. // name
  56. control.Name,
  57. // value
  58. control.Text,
  59. // onclick
  60. GetEvent("onchange", control, string.Format("document.getElementById('{0}').value", id)),
  61. // title
  62. id,
  63. control.MaxLength,
  64. control.Enabled ? "" : "disabled"
  65. );
  66. }
  67. }
  68. private string GetTextBoxStyle(TextBoxControl control)
  69. {
  70. return string.Format("{0}{1}", GetStandardStyle(control), GetControlAlign(control));
  71. }
  72. }
  73. }