【发布时间】:2016-04-29 07:42:58
【问题描述】:
这是场景,
我有一个包含 3 个用户控件的菜单的页面,当时只有一个 UC 可见。 每个 UC 都有自己的 GridView,以及各自的 RowCreated 事件。 我为每个 UC 的 RowCreated 事件设置了 3 个断点。
从页面上,当我访问其中一个 UC 时,比如说 UC_A,只有它的 RowCreated 事件正在触发,这很好。但是当我访问另一个 UC UC_B 时,UC_A 的 RowCreated 事件再次触发,之后 UC_B 的 RowCreated 事件是发射这是预期的行为..
在 UC 之间的切换之间执行的唯一代码是在父页面中:
Protected Sub dlMenu_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
UC_A.Visible = false
UC_B.Visible= true
UC_B.LoadPrincipalPage() 'Which has no code in common with the UC_A
End Sub
请注意,在父页面的 dlMenu_ItemCommand 之前触发了 RowCreated 事件。 为什么会这样?
【问题讨论】:
标签: asp.net vb.net gridview user-controls