|
| 1 | +@using Blazor.WebForm.UI |
| 2 | +@using Blazor.WebForm.UI.ControlComponents |
| 3 | +@using System.Web.UI |
| 4 | +@using System.Web.UI.WebControls |
| 5 | +@inherits WebControlComponent<System.Web.UI.WebControls.RichTextBox> |
| 6 | +@this.RenderWithInner(this.Control) |
| 7 | +@code { |
| 8 | + [Parameter] |
| 9 | + public RenderFragment ChildContent { get; set; } |
| 10 | + |
| 11 | + [Parameter] |
| 12 | + public string ValidationGroup |
| 13 | + { |
| 14 | + get |
| 15 | + { |
| 16 | + return this.Control.ValidationGroup; |
| 17 | + } |
| 18 | + set |
| 19 | + { |
| 20 | + this.Control.ValidationGroup = value; |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + [Parameter] |
| 25 | + public bool CausesValidation |
| 26 | + { |
| 27 | + get |
| 28 | + { |
| 29 | + return this.Control.CausesValidation; |
| 30 | + } |
| 31 | + set |
| 32 | + { |
| 33 | + this.Control.CausesValidation = value; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + [Parameter] |
| 38 | + public bool AutoPostBack |
| 39 | + { |
| 40 | + get |
| 41 | + { |
| 42 | + return this.Control.AutoPostBack; |
| 43 | + } |
| 44 | + set |
| 45 | + { |
| 46 | + this.Control.AutoPostBack = value; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + [Parameter] |
| 51 | + public string InnerHtml |
| 52 | + { |
| 53 | + get |
| 54 | + { |
| 55 | + return this.Control.InnerHtml; |
| 56 | + } |
| 57 | + set |
| 58 | + { |
| 59 | + this.Control.InnerHtml = value; |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + [Parameter] |
| 64 | + public HtmlTextWriterTag TextBoxTag |
| 65 | + { |
| 66 | + get |
| 67 | + { |
| 68 | + return this.Control.TextBoxTag; |
| 69 | + } |
| 70 | + set |
| 71 | + { |
| 72 | + this.Control.TextBoxTag = value; |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + [Parameter] |
| 77 | + public EventHandler OnTextChanged |
| 78 | + { |
| 79 | + get |
| 80 | + { |
| 81 | + return this.GetEventProperty(); |
| 82 | + } |
| 83 | + set |
| 84 | + { |
| 85 | + this.SetEventProperty(value, i => this.Control.TextChanged += i, i => this.Control.TextChanged -= i); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + protected override void OnInitialized() |
| 90 | + { |
| 91 | + base.OnInitialized(); |
| 92 | + if (this.HasPropertyBindEvent<string>(nameof(this.InnerHtml))) |
| 93 | + { |
| 94 | + this.Control.AutoPostBack = true; |
| 95 | + this.Control.TextChanged += this.BindInnerHtmlChanged; |
| 96 | + if (this.HasEventProperty(nameof(this.OnTextChanged))) |
| 97 | + { |
| 98 | + this.SetBindEventProperty(nameof(this.OnTextChanged), this.BindInnerHtmlChanged); |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + private void BindInnerHtmlChanged(object sender, EventArgs e) |
| 104 | + { |
| 105 | + this.InvokePropertyBindEvent(nameof(this.InnerHtml), this.InnerHtml); |
| 106 | + } |
| 107 | + |
| 108 | + protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters) |
| 109 | + { |
| 110 | + if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null) |
| 111 | + { |
| 112 | + this.InnerHtml = RenderUtility.GetContentString(this.ChildContent); |
| 113 | + } |
| 114 | + } |
| 115 | +} |
0 commit comments