TextBoxComponent.razor 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. @inherits DataFilterBaseComponent<TextBoxControl>
  2. @if(Control.Multiline)
  3. {
  4. <textarea style="@GetStyle"
  5. name="@Control.Name"
  6. disabled="@IsDisabled"
  7. maxlength="@Control.MaxLength"
  8. readonly="@Control.ReadOnly"
  9. @bind="@Text"></textarea>
  10. }
  11. else
  12. {
  13. <input style="@GetStyle"
  14. name="@Control.Name"
  15. type="text"
  16. disabled="@IsDisabled"
  17. maxlength="@Control.MaxLength"
  18. readonly="@Control.ReadOnly"
  19. @bind="@Text"/>
  20. }
  21. @code {
  22. public string Text
  23. {
  24. get => Control.Text;
  25. set
  26. {
  27. string correctValue = value.Replace("\n", "\r\n");
  28. Control.Text = correctValue;
  29. TextBoxChange(correctValue);
  30. }
  31. }
  32. private void TextBoxChange(string data)
  33. {
  34. Control.FilterData();
  35. Control.OnTextChanged(null);
  36. Refresh();
  37. }
  38. protected override string GetStyle
  39. => base.GetStyle + GetControlAlign();
  40. }