ImageButton 事件未在更新面板内触发

发布于 2024-07-14 05:07:49 字数 510 浏览 5 评论 0原文

这是我的问题的后续:

当可见设置为 true 时,不显示 Asp:Label?

在上面的问题中,我有一些控件的可见性未设置为 false,因为它们不在 UpdatePanel。 一旦我将控件放入 UpdatePanel 中,可见性的切换就起作用了,但这给我带来了另一个问题。 我有一个可导出到 Excel 的 ImageButton。 当按钮不在 UpdatePanel 中时,会触发 click 事件,但现在我将其放入 UpdatePanel 中,则不会触发 click 事件。

我还有一个下拉菜单,效果很好。 我认为这与 ImageButton 没有 AutoPostBack 属性有关。

This is sort of a follow-up to my question here:

Asp:Label is not shown when visible is set to true?

In the above question, I had a few controls where the visibility was not being set to false because they were not in an UpdatePanel. Once I put the controls inside an UpdatePanel, the toggling of visibility worked, but this has caused me another problem. I have an ImageButton that exports to excel. When the button was not in an UpdatePanel, the click event fired, but now that I put it inside an UpdatePanel, the click event does not fire.

I also have a dropdown which works fine. I am thinking it has something to do with the fact that the ImageButton does not have an AutoPostBack property.

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

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

发布评论

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

评论(8

荒人说梦 2024-07-21 05:07:49

ChildrenAsTriggers="true" 添加到您的更新面板。 如果您有母版页,则可以使用。

如果您的更新面板位于主面板中,则无法添加触发器。

Add ChildrenAsTriggers="true" to your update panel. Works if you have master pages.

If your update panel is in master you cannot add triggers.

海风掠过北极光 2024-07-21 05:07:49

我有类似的问题。 就我而言,ImageButtons 位于绑定到 updatepanel 的转发器内。 但我在中继器的 ItemDataBound 方法后面的代码中使用了 Page.RegisterRequiresRaiseEvent(ImageButton) 并且它起作用了。

I had the similar problem. In my case, ImageButtons are inside a repeater which is bound to a updatepanel. But I used Page.RegisterRequiresRaiseEvent(ImageButton) in the code behind within ItemDataBound method of the repeater and it worked.

黒涩兲箜 2024-07-21 05:07:49

确保您已将图像按钮关联到 UpdatePanel 上的 PostBackTrigger。 如果您使用类似于 Matt Berseth 的方法 的方法导出到 Excel,您可以让此触发器使导出工作。

<asp:PostBackTrigger ControlID="ImageButton1"/>

Make sure that you have associated the Image Button to a PostBackTrigger on the UpdatePanel. If you are exporting to Excel using something similar to Matt Berseth's method, you have to have this trigger for the export to work.

<asp:PostBackTrigger ControlID="ImageButton1"/>
只有一腔孤勇 2024-07-21 05:07:49

如果 itemTemplate 中有一个带有图像按钮的数据列表,则不需要触发器,但 causeValidation = false 是必需的。

If you had a datalist with an imagebutton in the itemTemplate, the trigger is not required but causeValidation = false is.

你是暖光i 2024-07-21 05:07:49

不,ImageButtons 没有 AutoPostBack:它们不像普通按钮那样需要它们。

这种行为听起来很奇怪。 我想说首先要尝试的是将 asp:ImageButton 更改为 asp:Button 并查看是否会改变行为。 如果不是,那么它是一个 ImageButton 的事实就是一个转移注意力的事实。

No, ImageButtons don't have AutoPostBack: they don't need them any more than regular buttons do.

That behaviour sounds pretty weird. I'd say the first thing to try would be to change the asp:ImageButton into an asp:Button and see if that changes the behaviour. If not, the fact that it's an ImageButton is a red herring.

难以启齿的温柔 2024-07-21 05:07:49

尝试用菜单(包含单个菜单项)替换 imagebutton 并设置其 imageurl 属性。

Try replacing the imagebutton with a menu (which contains a single menu-item) and set the imageurl property thereof.

蓝戈者 2024-07-21 05:07:49

将“CausesValidation”属性更改为 false。

change the 'CausesValidation' attribute to false.

那些过往 2024-07-21 05:07:49
myImagebutton.OnClientClick = "return true;";
myImagebutton.OnClientClick = "return true;";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文