问题标签 [raiseevent]

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 投票
1 回答
3985 浏览

javascript - 从 javascript (VB.NET) 执行代码隐藏 Function/Sub

在我的项目中,有 3 个用户控件;BasicContact、BasicDetail 和 ActionTime。它们在 EditOrder.aspx 页面中。

BasicContact 中有“ReportDate”属性(日期类型),BasicDetail 中有 RadioButtonList“rdl_Priority”(具有“prio_id”字段中的整数值),ActionTime 中有“CheckDate”属性。ReportDate 值派生自 txt_ReportDate 和 txt_ReportTime,而 CheckDate 值派生自 txt_CheckDate 和 txt_CheckTime。

我的目标是在将日期添加到 ReportDate 并单击单选按钮列表后计算 Checkdate。Checkdate 将根据 ReportDate(日期)+ SLAHour(小时,从输入为 prio_id 的“GetSLAHour”方法获取)计算,然后在 txt_CheckDate 和 txt_CheckTime 中设置文本。

现在,我能够使用 Postback 完成这项任务。我创建自定义事件并在 RadioButtonList selectedIndexchanged 方法中引发它。之后,事件在 EditOrder 页面后面的代码中处理。这是我的代码。

BasicDetail - RadioButtonList

BasicDetail - codeBehind

EditOrder - 代码隐藏

但是,我不希望刷新页面(没有回发)。我不知道如何从 javascript 调用函数或子函数。我已经尝试过 PageMethod 但它在运行时导致错误,说该方法不受支持。无论如何,如果有比从 javascript 调用代码隐藏更好的方法,请告诉我。

提前致谢

0 投票
4 回答
1289 浏览

c# - 从 c# 到 vb.net 的代码转换,包括事件处理程序

您好,我发现了一个用 c# 编写的很棒的类,我想在 VB.NET 项目中使用它。

我在这个线程中找到了它: C#:重定向控制台应用程序输出:如何刷新输出?

C# 类如下所示:

我的转换代码如下所示:

错误 1-3 似乎是警告,实际上可能有效,尤其是错误 4 和 5 让我头疼“公共事件 OutputDataRecieved(sender As Object, e As DataRecievedEventArgs) 是一个事件,不能直接调用。使用 RaiseEvent 语句引发一个事件。”

事件处理程序似乎不适用于我尝试过的任何代码转换器,而且我缺乏手动转换它的 VB 技能。

是否有一个友好的灵魂可以正确地转换这个类以使其真正起作用?

非常感谢!

罗马

0 投票
2 回答
18644 浏览

events - 将 c# 转换为 vb.net 'RaiseEvent' 语句以引发事件以使用 Gzip

我已经将类从 c# 转换为 vb.net .. 我的观点是我想压缩 asp.net 页面以减小页面大小,问题是在我转换为 vb.net 之后,我有这个错误

说明:在编译服务此请求所需的资源期间发生错误。请查看以下特定错误详细信息并适当修改您的源代码。

编译器错误消息:BC32022:“Public Event PostRequestHandlerExecute(sender As Object, e As System.EventArgs)”是一个事件,不能直接调用。使用“RaiseEvent”语句来引发事件。

源错误:

第 178 行:

第 179 行:Private Sub Init(context As HttpApplication) 实现 IHttpModule.Init

第 180 行: context.PostRequestHandlerExecute += New EventHandler(context_BeginRequest)

第 181 行:结束子

第 182 行:

我正在尝试为 asp.net 实现 Gzip ......在此先感谢......

0 投票
0 回答
105 浏览

asp.net - 验证时出现错误,我该如何退出

我有一个特定的网络表单,当用户点击

保存按钮它调用我的dbEngineClass中的函数 save() 。

现在,当用户输入重复数据时,我会引发某个错误并在网页中处理它

显示某个消息框,但之后我希望它退出课程而不是这样做

还要别的吗

但显然它将继续执行btnsave.click sub

如果出现错误,我如何退出课程或阻止单击方法继续?

这是我的代码:这是保存信息并引发事件的函数

这是我在网页中处理它的方式

现在,在此处理程序完成后,我需要它退出并且不要继续 btnSave.click

调用SaveNewCustomer() 子的处理程序,因为当它继续时它会清除所有

数据,我不想要那个

0 投票
2 回答
205 浏览

wpf - 由 UI 或代码引发的 WPF 事件?

如何确定事件是由 UI 还是由代码引发的?我需要识别滑块的值是否由用户从 UI 更改或具有来自执行代码的新值?

谢谢!

0 投票
5 回答
68491 浏览

vb.net - 如何在 VB.NET 代码中触发事件?

我有一个带有开始按钮的表单(允许用户根据需要反复运行进程),并且我想btnStart.Click在表单加载时发送一个事件,以便进程自动启动。

我有以下btnStart.Click事件功能,但我如何真正告诉 Visual Basic '假装有人点击了按钮并触发此事件'?

我试过很简单,这基本上是有效的。但是,Visual Studio 给了我一个警告Variable 'sender' is used before it has been assigned a value,所以我猜这不是真正的方法:

我也尝试过使用RaiseEvent btnStart.Click,但这会出现以下错误:

'btnStart' 不是 'MyProject.MyFormClass 的事件

代码

0 投票
3 回答
2407 浏览

c# - 有没有没有引发表单的激活事件的情况?

我不明白为什么会这样,我认为在显示表单时应该提出 Activated 。事实上,我的表单已将 TopLevel 设置为 false,并且它已添加到另一个表单中。当主窗体显示时,它也是可见的,我可以与它的控件进行交互,但我测试并看到 Activated 没有被提升。

运行 MainForm 后,子窗体出现在主窗体中,并且没有显示任何带有消息“已激活!”的 MessageBox。

增加它的额外工作是什么?

0 投票
1 回答
734 浏览

vb.net - pass datarow from a different form using multiple RaiseEvents

I've got two forms. frmProject has an ultragrid of system rows. When I double-click on a row, it opens frmSystem, displaying textboxes populated with details from the active row on frmProject.

I want frmSystem to load the same values as that specified in the ultragridrow on frmProject. I don't want frmSystem to load values from the database table tbl_System. This is because if a user makes changes in frmSystem, those changes are copied back to the dataset behind frmProject (via RaiseEvent RefreshSystemsData) when frmSystem is saved and closed. If the user decides to open frmSystem for the same System row again, populating from the database would show out-of-date values. So I want frmSystem to load its values via copying from the dataset row in frmProject.

In light of this, I added another RaiseEvent to trigger when frmSystem opens. The idea was to read in the System datarow from frmProject.

However, it appears that this RaiseEvent present in each form (referring to each other) is perhaps causing an out of memory exception. The application will not load unless I comment out the code related with PopulateSystemsData and SendSystemDataTofrmSystem.

I would have liked to pass the datarow as a parameter into the InvokeCommand subroutine - but all forms in the database are opened via subroutines in frmMain which contains a whole bunch of other code to do with initialising forms etc etc which I don't want to touch.

I thought about passing the datarow as a series of strings to Options() array in InvokeCommand(), but that would mean all values on frmSystem would be converted to strings, which wouldn't work.

I tried changing the InvokeCommand constructor etc but it started getting really complicated, and I don't want to break the entire application!

I didn't know whether a public function might do it, but I need the datarow to be passed when frmSystem is opened, and it's the frmMain code that handles that.

I need the datarow values at time of InvokeCommand() subroutine execution (done by frmMain).

Any ideas how I can solve this? Here's a cut-down version of the forms code. Thanks in advance for your help.

0 投票
2 回答
3992 浏览

.net - 如何在 VB.NET 中引发事件之前检查订阅者

在 C# 中,您可以执行以下操作:

但是你在 VB.NET 中做什么呢?

RaiseEvent,但是是

实际检查是否有东西订阅了该事件?

0 投票
2 回答
4545 浏览

vb.net - 从另一个控件触发事件

我正在使用 vb.net 和 winform。我遇到了一个问题,在过去的几个小时里我一直在努力解决这个问题。

我有一个主用户控件,我添加了一个组框,并在该组框内添加了一个这样的控件:

主用户控件

用户控件 ctlWithDropDown

主用户控件继承了基类,该基类具有将值设置为 true 或 false 的事件,如下所示:

我想知道在触发 SelectionChanged 事件时如何从下拉列表中触发/设置此布尔值。对这个问题有任何帮助吗?