从另一个 UpdatePanel ASP.Net 访问视图内的 UpdatePanel

发布于 2024-07-12 06:23:01 字数 409 浏览 4 评论 0原文

我有两个 updatePanel

  • UpdatePanel1 包含一个按钮
  • UpdatePanel2 位于 Multiview View1: 内

<Multiview>
  <View1>
    <UpdatePanel2>
    </UpdatePanel2>
  </View1>
</Multiview>

多视图 ActiveIndex 设置为 -1。

现在我在 UpdatePanel2 上附加了一个与按钮单击关联的 AsyncPostBackTrigger。

我想在单击 UpdatePanel1 中的按钮时显示 View1。

I have two updatePanels

  • UpdatePanel1 contains a button
  • UpdatePanel2 is inside a Multiview View1:

.

<Multiview>
  <View1>
    <UpdatePanel2>
    </UpdatePanel2>
  </View1>
</Multiview>

Multiview ActiveIndex is set to -1.

Now I have attached an AsyncPostBackTrigger on UpdatePanel2 which is associated with the button click.

I want to show View1 when I click the button in UpdatePanel1.

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

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

发布评论

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

评论(1

逆光飞翔i 2024-07-19 06:23:01

您需要将更新面板放在 MultiView 周围,而不是 View1 内部:

<UpdatePanel2><MultiView><View1></View1></MultiView></UpdatePanel2>

UpdatePanel 将在页面上呈现为 div 或 span(默认为 div)。

当您执行回调时(例如,当您单击 UpdatePanel 内的按钮时),ASP.NET 会向浏览器发送一条消息,告诉它如何更新代表 UpdatePanel 的 div 的内容。 该消息是在 JavaScript 中接收和处理的。

如果您首次到达该页面时未显示 View1,则 UpdatePanel2 根本不会呈现。 因此,当您的按钮单击导致回调时,呈现的页面上没有 div 可供 javascript 更改其内容。

You're going to need to put the update panel around the MultiView, rather than inside View1:

<UpdatePanel2><MultiView><View1></View1></MultiView></UpdatePanel2>

An UpdatePanel will render on the page as either a div or a span (a div by default).

When you do a callback (such as when you click the button inside the UpdatePanel), ASP.NET sends a message to the browser telling it how to update the contents of the divs that represent your UpdatePanels. This message is received and handled in javascript.

If you're not showing View1 when you first arrive at the page, then UpdatePanel2 won't get rendered at all. Therefore, when your button click causes the callback, there's no div on the rendered page for javascript to change the contents of.

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