@@ -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 ) ;
0 commit comments