ASP UpdatePanel和OPC [英] ASP updatepanel and OPC
问题描述
大家好,
作为我在这里的第一篇文章,我想打个招呼. :-D
我正在研究ASP.NET项目,我想读取OPC-DA数据.数据读取工作正常,但是我无法使updatepanel自动刷新.
当新数据到达时,"OpcGroup"对象将引发"DataChange"事件.在这种情况下,我想手动刷新更新面板(有条件的).所以我在UpdatePanel1上设置了updatemode = conditional.当我用鼠标单击更新按钮时,更新就起作用了.但是,当我以编程方式单击按钮时,更新无法正常进行.
有谁知道为什么这行不通(或更好的主意)?
Hi All,
Being my first post here, I''d like to say hello. :-D
I''m working on a ASP.NET project and I wan''t to read OPC-DA data. The data reading works fine, but I can''t get the updatepanel to refresh automatically.
When new data arrives, a ''DataChange'' event is thrown by the ''OpcGroup'' object. In this event I want to refresh the update panel manually (conditional). So I''ve set the updatemode=conditional on the UpdatePanel1. When I click the update button with my mouse, the update works. But when I click the button programmatically, the update doesn''t work.
Does anyone have an idea why this doesn''t work (or a better idea)?
Private Sub objOpcGrps_DataChange(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles As System.Array, ByRef ItemValues As System.Array, ByRef Qualities As System.Array, ByRef TimeStamps As System.Array) Handles objOpcGrp.DataChange
'declaration
Dim i As Integer
'update status tags
For i = 1 To ClientHandles.Length
If ClientHandles(i) = 1 Then txtWaarde3.Text = ItemValues(i)
If ClientHandles(i) = 2 Then txtWaarde3.Text = ItemValues(i)
Next
'Click update button to refresh updatepanel
btnUpdate_Click(btnUpdate, New System.EventArgs)
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
UpdatePanel1.Update()
End Sub
推荐答案
直接调用其他更新面板的更新.
试试:
Call the update of other update panel directly.
Try:
Private Sub objOpcGrps_DataChange(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles As System.Array, ByRef ItemValues As System.Array, ByRef Qualities As System.Array, ByRef TimeStamps As System.Array) Handles objOpcGrp.DataChange
'declaration
Dim i As Integer
'update status tags
For i = 1 To ClientHandles.Length
If ClientHandles(i) = 1 Then txtWaarde3.Text = ItemValues(i)
If ClientHandles(i) = 2 Then txtWaarde3.Text = ItemValues(i)
Next
' Call the update of the other update panel here itself
UpdatePanel1.Update()
End Sub
不能按预期工作的原因是由于页面生命周期以及单击的方式和调用时间.
The reason it does not work as you intend to is because of the page life-cycle and the way and when the click has been called for.
这也不起作用.
现在我得到一个错误:只能在渲染之前在ID为"UpdatePanel1"的UpdatePanel上调用Update方法.
This isn''t working either.
Now I get error: The Update method can only be called on UpdatePanel with ID ''UpdatePanel1'' before Render.
这篇关于ASP UpdatePanel和OPC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!