0

This is for ASP.NET. Think about the multiview control. It has 1 to many view controls. Each view control has the ability of holding controls, but, yet, only one view is visible at a time.

Keeping that in mind, I'm thinking I want to "tell" the non-visible views to NOT LOAD, therefore, NOT LOADING the child controls.

In my sample, during the view's load, I check to see if it is the active view. If it is not active, then I stop processing the load. Unfortunately, views that are not active still have their load event run and all the controls in the control tree run their load.

Back to the question: Is there a way to stop the child controls from running for the view that is not active?

Code Sample:

Private Sub viewDisplayArticle_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles viewDisplayArticle.Load

  If Not mvwHealthArticles.ActiveViewIndex = mvwHealthArticlesView.DisplayArticle Then Exit Sub

  callSomeKillerMethod()

End Sub
4

1 に答える 1

1

非表示の子コントロールのVisibleプロパティを False に設定し、Visible が true の場合にのみ、子コントロールで Load イベント ハンドラーを実行します。

Private Sub viewDisplayArticle_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles viewDisplayArticle.Load

  If Visble = True
  Then ' Load Logic
  Else ' do nothing

End Sub
于 2009-09-08T20:38:05.033 に答える