问题标签 [addhandler]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
102 浏览

c# - Using my c# event in VB.NET

I have written a DLL in C#, and I would like to get callback from an event.

In C# I dit it the following way:

I tried the same in VB.NET, but the IDE already complains about my AddHandler approach:

The C# implementation works fine, but in VB.NET, the IDE tells me that "Zipper" and "ProgressChangedEventArgs" are a type and cannot be used as an expression.

Can somebody tell me what I am doing wrong here? Also, it tells me that

0 投票
1 回答
188 浏览

asp.net - 动态按钮 - onclick 不起作用

我在其他几个项目中使用过这段代码,但这次我无法让它工作。

我正在尝试跟踪按钮控件的单击事件,但它只是没有触发。

我已经尝试重新加载 page.init 中的控件(我必须将 ControlsToLoad 从 viewstate 更改为 session 才能再次加载控件)但这也不起作用。

这是我用于测试目的的页面:

任何帮助表示赞赏。

谢谢

0 投票
1 回答
431 浏览

vb.net - DataGridViewRowsAdded 处理程序给出错误

我正在尝试将RowsAddedandCellFormatting处理程序添加到我的项目中。我似乎已经清除了CellFormatting处理程序中的所有错误,但我RowsAdded给出了一些我无法弄清楚的错误。

未为“Public Sub New(rowIndex As Integer, rowCount As Integer)”的参数“rowCount”指定参数

“AddressOf”表达式无法转换为“Integer”,因为“Integer”不是委托类型

我的代码:

关于错误,我没有在任何地方使用 rowCount 所以也许我需要?

为什么它认为我使用整数作为委托类型?

我检查了,我没有任何公共变量 rowCount 或 rowIndex。


根据答案,我删除了 Sub InitializeDataGridView() 中的两行,这似乎解决了我的错误。然而,答案还指出 Args 应该是 Handler。所以我将 Private Sub OnRowsAdded 更改为

这导致了一堆新的错误,所以我撤消了它。为什么这会导致错误?

0 投票
0 回答
526 浏览

xmpp - Strophe addHandler 不起作用

这是一个与“Strophe.Connection.addHandler no works if call Strophe.Connection.sendIQ”相关的问题,但它对我没有帮助。我正在尝试运行“Wrox Professional XMPP Programming with JavaScript and jQuery Book”一书的程序,这是一个协作编辑器。

问题是 NetPad.on_disco_info(iq) 在与另一个合作者建立连接时不会被触发,尽管发送了一个 iq 节。我省略了 addHandler 的其余参数,以获取所有 iq 但又一无所获。我的服务器是 ejabberd。请问有什么不明白的地方。

0 投票
1 回答
360 浏览

.net - VB.NET 中 SystemEvents 的 Handles 声明和 AddHandler 的区别

我正在使用一个设备驱动程序,当系统进入睡眠状态时我需要关闭它。我想我可以将SystemEvents.PowerModeChanged事件的处理程序添加到 ApplicationEvents.vb,如下所示:

使用Handles关键字处理事件。但是,Handles 子句存在编译错误:

WithEvents 似乎总是为我在 .NET 中遇到的其他事件定义的,那么为什么这个不同呢?我更喜欢使用 Handles 子句,因为这会自动添加和删除处理程序。它还保持功能自包含,而不是将其分布在初始化程序、析构函数和函数本身之间。是否可以在此事件上使用 Handles 声明?

这个问题的一个线索是以下代码确实有效:

0 投票
1 回答
985 浏览

vb.net - VB.NET AddHandler 正在创建窗体的新实例。导致空委托

该线程被标记为重复,因为我之前遇到过这个问题并且之前曾问过一个问题。我现在通常知道如何解决它(即通过使用指向表单实例而不是其名称的变量)。不过这次是我需要参考的默认启动表单。所以没有变量存储它的实例,我不知道如何在没有变量的情况下引用它的现有实例。

我有 2 个表单(frmMain 和 frmStatus) 我创建了一个 frmStatus 实例并将其存储在 frmMain 上的 statusDialog 变量中。然后我创建一个新线程(用于我的 ADSearcher 类),它触发事件,然后使用委托调用 statusDialog 上的子程序。ADSearcher 线程还创建了多个其他线程(对于我的 ComputerSearcher 线程),这些线程还需要引发事件,这些事件将使用委托在 statusDialog 上调用 subs。

问题出在 ComputerSearcher 线程中。AddHandler 行似乎正在创建一个新的 frmMain 实例,这意味着 statusDialog 为 Nothing/Null。为什么 AddHandler 创建表单的新实例,有没有办法让它使用正确的实例?

我认为它正在创建一个新实例的原因是因为当我单步执行代码时,它会执行第一行 AddHandler ,然后单步执行 frmMain 顶部的变量声明(在任何 subs 之外),此时 statusDialog 变为 Nothing。

起点是 Private Sub mnuSync_ADSync_Click(...)。这将创建第一个线程和类实例。我已经尝试提供足够的代码让您在不发布大量文章的情况下查看正在发生的事情。如果您需要任何其他代码,请询问。

提前致谢,

主界面

ADSearcher 类

计算机搜索类

0 投票
2 回答
94 浏览

php - 带有 .html 扩展名的 OpenShift PHP

众所周知,通过在 http.conf 中添加以下行,很容易让 Apache 将 .html 页面作为 PHP 页面处理: AddHandler application/x-httpd-php .php .html

如何在 OpenShift 中做到这一点?

如何在 OpenShift 中编辑 http.conf?

还是有其他方法?

0 投票
3 回答
763 浏览

vb.net - VBScript 中 AddHandler 的语法错误

首先,我是 VB 语言、VB 脚本和 VB.net 编程的新手,但在其他语言和平台方面相当擅长。

我的目标是从命令行运行一个简单的基于 VB 的程序并让它弹出一个消息框(那部分我想通了)。此外,如果计算机同时进入睡眠模式(或从睡眠模式恢复),我希望消息框(以及脚本)终止。

我在 VBForums 上找到了有关处理程序的代码:

所以我制作了一个使用上述(第一个版本)的 .vbs 文件并运行它:

但是我遇到了各种语法错误(on As,AddressOf等)。经过一些测试和谷歌搜索后,我开始意识到一些 VB 实体似乎更严格的类型,并且比其他实体具有更进化的语法。所以这是我的第二个版本,它几乎成功地通过了语法阶段:

现在口译员在电话线上抱怨“要求:'Microsoft'” AddHandler。在这一点上,我不知道该怎么办。我试过Microsoft.AddHandler但没有奏效。

所以如果你能帮我修复这条线,我将不胜感激,并告诉我是否有任何其他东西可以使这个小程序正常工作。

谢谢你。

0 投票
2 回答
1322 浏览

vb.net - dynamically create a new tab with textbox, button in the tab with click and keypress events (AddHandler is what i cant get to work)

I am creating some tabs and I need two things to work that I can't get to work. I need to AddHandler for a Textbox.Keypress event AND a Button.Click event. I can make these things work outside of the tabcontrol but not in.

In the example below my text box and buttons have same name from on tab to the another, I thought that might be my problem but even changing names between tabs does not work. I assume I need to be more specific in the AddHandler part to give the tab name as well as control. There is a logic in my real code to allow me to give unique names to each tab panel and controls, but i can't get the simple part to work.

I left some of the things I tried commented, but I tried LOTS and LOTS of other things.

0 投票
1 回答
129 浏览

asp.net - ASP VB 卡在动态控件、视图状态和回发上。真的可以使用一些帮助来回到正轨

我一直在阅读帖子和文章,只是有点困惑,因此我现在没有时间燃烧

有人可以查看我的代码并告诉我哪里出错了吗?