Skip to content

Commit 6f984bd

Browse files
committed
1.1.8.5
1 parent 1d7b956 commit 6f984bd

13 files changed

Lines changed: 40 additions & 37 deletions
-86.7 KB
Binary file not shown.
86.8 KB
Binary file not shown.

Blazor.WebForm.Components/Base/BaseValidatorControlComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ protected override void OnInitialized()
100100
}
101101
}
102102

103-
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
103+
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
104104
{
105-
base.SetInnerPropertyWithInner(parameters, ref hasInnerContent);
105+
base.SetInnerPropertyWithInner(parameters);
106106
if (!parameters.ContainsKey(nameof(this.ID)) && string.IsNullOrEmpty(this.ID))
107107
{
108108
this.ID = Guid.NewGuid().ToString("N");

Blazor.WebForm.Components/Base/ControlComponentBase.cs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public abstract class ControlComponentBase<TControl> : ControlComponent<TControl
2323
private IReadOnlyDictionary<string, object> _parameters;
2424
private bool _renderedWithCascading;
2525
private bool _renderedWithInner;
26-
private bool _hasRenderedChildContent;
26+
private TemplateControl _templateControl;
2727

2828
//new public virtual TControl Control
2929
//{
@@ -226,6 +226,18 @@ EventHandlerDictionary IParameterViewComponent.Events
226226

227227
List<string> IControlParameterViewComponent.ReserveParameters { get; set; }
228228

229+
public TemplateControl TemplateControl
230+
{
231+
get
232+
{
233+
if (_templateControl == null)
234+
{
235+
_templateControl = (this.Control as IVirtualNamingContainer).TemplateControl;
236+
}
237+
return _templateControl;
238+
}
239+
}
240+
229241
//public void DataBind()
230242
//{
231243
// this.Control.DataBind();
@@ -321,10 +333,6 @@ protected RenderFragment RenderWithCascading<TValue>(TValue control, RenderFragm
321333
if (!_renderedWithCascading)
322334
{
323335
_renderedWithCascading = true;
324-
if (childContent != null && childLevel == 0)
325-
{
326-
_hasRenderedChildContent = true;
327-
}
328336
return RenderUtility.RenderWithCascading(control, childContent, childLevel, this.RenderWithCascading);
329337
}
330338
else
@@ -333,7 +341,7 @@ protected RenderFragment RenderWithCascading<TValue>(TValue control, RenderFragm
333341
}
334342
}
335343

336-
protected virtual void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
344+
protected virtual void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
337345
{
338346

339347
}
@@ -343,39 +351,39 @@ protected RenderFragment RenderWithInner<TValue>(TValue control) where TValue :
343351
if (!_renderedWithInner)
344352
{
345353
_renderedWithInner = true;
346-
bool hasInnerContent = false;
347-
this.SetInnerPropertyWithInner(_parameters, ref hasInnerContent);
348-
if (hasInnerContent)
349-
{
350-
_hasRenderedChildContent = true;
351-
}
354+
this.SetInnerPropertyWithInner(_parameters);
352355
}
353356
return this.Render(control);
354357
}
355358

356359
protected override void OnUpdate(object sender, EventArgs e)
357360
{
358361
base.OnUpdate(sender, e);
359-
this.SendMessage("RequestRefresh");
362+
this.SendMessage("RequestRefresh", this.TemplateControl);
360363
}
361364

362365
[MessageNotifyMethod]
363-
protected void RequestRefresh()
366+
protected void RequestRefresh(TemplateControl control)
364367
{
365-
if (!_hasRenderedChildContent)
368+
if (control != this.TemplateControl)
366369
{
367-
this.StateHasChanged();
370+
return;
368371
}
372+
this.StateHasChanged();
369373
}
370374

371375
protected virtual void OnSubmit(object sender, EventArgs e)
372376
{
373-
this.SendMessage("RequestLoadPostData");
377+
this.SendMessage("RequestLoadPostData", this.TemplateControl);
374378
}
375379

376380
[MessageNotifyMethod]
377-
protected void RequestLoadPostData()
381+
protected void RequestLoadPostData(TemplateControl control)
378382
{
383+
if (control != this.TemplateControl)
384+
{
385+
return;
386+
}
379387
if (this.Control is IPostBackDataHandler)
380388
{
381389
this.LoadPostData(false);

Blazor.WebForm.Components/Base/ControlComponentExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ namespace Microsoft.AspNetCore.Components
1111
{
1212
public static class ControlComponentExtensions
1313
{
14-
public static void RequestRefresh<T>(this ControlComponent<T> component) where T : Control, new()
14+
public static void RequestRefresh<T>(this TemplateControlComponent<T> component) where T : TemplateControl, new()
1515
{
1616
component.LoadPostData();
17-
ControlComponentReflection<T>.SendMessageExtensionMethod(component, "RequestRefresh");
17+
ControlComponentReflection<T>.SendMessageExtensionMethod(component, "RequestRefresh"
18+
, arguments: new object[] { component.Control });
1819
}
1920
private class ControlComponentReflection<T> where T : Control, new()
2021
{

Blazor.WebForm.Components/Base/LabelControlComponent.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ public string Text
2828
}
2929
}
3030

31-
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
31+
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
3232
{
3333
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
3434
{
35-
hasInnerContent = true;
3635
this.Text = RenderUtility.GetContentString(this.ChildContent);
3736
}
3837
}

Blazor.WebForm.Components/Blazor.WebForm.Components.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net5.0</TargetFramework>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>Blazor.WebForm.Components.pfx</AssemblyOriginatorKeyFile>
7-
<Version>1.1.8.4</Version>
7+
<Version>1.1.8.5</Version>
88
<RootNamespace>asp</RootNamespace>
99
<Copyright>Jurio li</Copyright>
1010
<AssemblyName>Blazor.WebForm.Components</AssemblyName>
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Applied" Version="1.2.1.5" />
20-
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.8.4" />
20+
<PackageReference Include="Blazor.WebForm.UI" Version="1.1.8.5" />
2121
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.8" />
2222
</ItemGroup>
2323

Blazor.WebForm.Components/Button.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@
153153
_command.Invoke(sender, e);
154154
}
155155

156-
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
156+
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
157157
{
158158
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
159159
{
160-
hasInnerContent = true;
161160
this.Text = RenderUtility.GetContentString(this.ChildContent);
162161
}
163162
}

Blazor.WebForm.Components/CheckBox.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,10 @@
130130
this.InvokePropertyBindEvent(nameof(this.Checked), this.Checked);
131131
}
132132

133-
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
133+
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
134134
{
135135
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
136136
{
137-
hasInnerContent = true;
138137
this.Text = RenderUtility.GetContentString(this.ChildContent);
139138
}
140139
}

Blazor.WebForm.Components/HyperLink.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@
8686
}
8787
}
8888

89-
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters, ref bool hasInnerContent)
89+
protected override void SetInnerPropertyWithInner(IReadOnlyDictionary<string, object> parameters)
9090
{
9191
if (parameters.ContainsKey(nameof(this.ChildContent)) && this.ChildContent != null)
9292
{
93-
hasInnerContent = true;
9493
this.Text = RenderUtility.GetContentString(this.ChildContent);
9594
}
9695
}

0 commit comments

Comments
 (0)