您可以使用以下代码使列表框出现在下拉列表值的任何更改上
Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
Dim cs As ClientScriptManager = Page.ClientScript
cs.RegisterClientScriptBlock(Me.GetType(), "MyScript", "<script type=""text/javascript""> Alert("Ok"); </script>", False);
ListBox1.Visible = True
End Sub
但是,如果您想在用户选择第一个/第二个或第 n 个项目时进行更改,您可以使用此
Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
Dim cs As ClientScriptManager = Page.ClientScript
cs.RegisterClientScriptBlock(Me.GetType(), "MyScript", "<script type=""text/javascript""> Alert("Ok"); </script>", False);
if DropDownList2.SelectedIndex = 0 //makes the listbox visible only when you select the first item, Use 1 for making the list box visible on the selection of the second item, so on and so forth.
ListBox1.Visible = True
end if
End Sub