为什么一个按钮控制需要被点击两次? [英] Why does a button control need to be clicked twice?

查看:406
本文介绍了为什么一个按钮控制需要被点击两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序使用VB和Ajax的工作。我使用的UpdatePanel,以避免回发到服务器的刺激性的忽悠。

I've got a web application working using VB and Ajax. I'm using updatepanels to avoid the irritating "flicker" on postbacks to the server.

我想有自己的UpdatePanel中定义的按钮控制(外尝试移动它,并得到了一些灾难性的错误,所以离开那里),使得当前面板不可见和兄弟姐妹面板可见。这适用于该按钮必须被点击两次除外。不双点击,点击,但比一次再次点击。

I would like to have a button control defined within the updatepanel itself (tried moving it outside and got some catastrophic error, so left it there) that makes the current panel not visible and a sibling panel visible. This works with the exception that the button must be clicked twice. Not double clicked, but clicked once than clicked again.

在设置断点我发现落后于code附加到实际上是被第一个点击执行按钮,但是按预期面板不切换。如果我点击该按钮或者更糟的是,不同的按钮,第二盘的出现会出现预期的行为。然而,被点击第二个按钮有显示第三小组不必要的奖金,第三小组正在取得可见,由于被点击第二个按钮。

In setting breakpoints I discovered the code behind that's attached to the button is actually being executed on the first click, but the panels don't switch as expected. If I click the same button OR worse yet, a different button, the expected behavior of the second panel appearing occurs. However, with the second button being clicked there's an unwanted bonus of a third panel being displayed, the third panel being made visible due to the second button being clicked.

我假设这种行为是由于在UpdatePanel和Ajax的性质。有没有一种方法,以避免第二次点击?我是不是滥用的UpdatePanel?我真的想用一个模式弹出(右走出AjaxToolKit),但曾与,所以我选择了这种方法回发数据的问题。任何见解,援助,甚至批评是因为这已经困扰我很长时间受到欢迎。谢谢

I'm assuming this behavior is due to the updatepanel and its Ajax nature. Is there a way to avoid the second click? Am I misusing the updatepanel? I really wanted to use a modal popup (right out of the AjaxToolKit) but had problems with posting back the data so I opted for this approach. Any insights, assistance, even criticism would be welcome as this has plagued me long enough. Thanks

推荐答案

我觉得你的问题是,只有更新面板从服务器接收数据的方法执行后。你正在试图改变面板更新面板之外,因此它不会知道它的性质已经改变。

I think your problem is that only the update panel is receiving data from the server after the method executes. The panel your are trying to change is outside of the update panel so it does not know that its properties have changed.

您要么需要做一个完整的网页回发或想有一个更新面板内修改面板。

You either need to do a full page postback or have the panel you wish to modify inside the update panel.

这篇关于为什么一个按钮控制需要被点击两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆