我有一个 treeview asp.net 控件。我有以下 Treeview1 的 SelectedNodeChanged 事件。
Private Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
Try
Dim type As Boolean = False
Dim nodetext As String = TreeView1.SelectedNode.Value
Dim depth As Integer = TreeView1.SelectedNode.Depth
If nodetext = "Root" Then
btnCreateComp.Visible = True
btnCreateComp.Text = "Create Company"
btnCreateUser.Visible = False
Else
type = getNodeType(nodetext)
'if it is true its USER
'if false it is COMPANY
If type = True Then
btnCreateComp.Visible = False
btnCreateUser.Visible = True
btnCreateUser.Text = "Edit User"
btnCreateUser.PostBackUrl = "~/Account/User.aspx"
Else
btnCreateComp.Visible = True
btnCreateComp.Text = "Edit Company"
btnCreateUser.Visible = True
btnCreateUser.Text = "Create User"
btnCreateUser.PostBackUrl = "~/Account/User.aspx"
End If
End If
Catch ex As Exception
End Try
End Sub
当我点击一个节点时,如果它不是“root”,它会显示 2 个按钮,如果我点击 btnCreateUser 按钮,它会转到一个页面“user.aspx”,这是 btnCreateUser 的 postbackurl。
这可以。但是当下一次单击“Root”以外的节点时,它直接转到postbackurl页面“User.aspx”,即使我没有单击按钮btnCreateUser。
这仅在我第一次单击“btnCreateUser”后发生一次。
有人可以帮忙吗?