如何阻止 Web 控件加载子控件?

发布于 2024-08-04 09:11:00 字数 551 浏览 4 评论 0原文

这是针对 ASP.NET 的。考虑一下多视图控制。它有一对多视图控件。每个视图控件都具有保持控件的能力,但是一次只有一个视图可见。

记住这一点,我想我想“告诉”不可见视图不加载,因此不加载子控件。

在我的示例中,在视图加载期间,我检查它是否是活动视图。如果它不活动,那么我将停止处理负载。不幸的是,不活动的视图仍然运行其加载事件,并且控件树中的所有控件都运行其加载。

回到问题:有没有办法阻止子控件为不活动的视图运行?

代码示例:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一袭白衣梦中忆 2024-08-11 09:11:00

设置不可见子控件的可见 属性设置为 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

Set the non visible child control's Visible property to False, and then only run the Load event handler in the child controls when Visible is true.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文