2 Asp.net lisboxs with autopostback true
During first load this is shown "lsb1Blsb2A" when i select lsb1B. The problem is that both listboxs method fire at the same time. My goal is
to make it show only lsb1B. Please tell me what I am doing wrong.
Code behind
<script runat="server">
sub page_load(obj as object , e as eventargs)
if not page.ispostback then
dim arlst1 as new arraylist
dim arlst2 as new arraylist
arlst1.add("lsb1A")
arlst1.add("lsb1B")
arlst1.add("lsb1C")
arlst2.add("lsb2A")
arlst2.add("lsb2B")
arlst2.add("lsb2C")
lsb1.datasource=arlst1
lsb1.databind
lsb2.datasource=arlst2
lsb2.databind
end if
end sub
sub lsb1hdl(ByVal sender As Object, ByVal e As EventArgs)
response.write(lsb1.selecteditem.text)
end sub
sub lsb2hdl(ByVal sender As Object, ByVal e As EventArgs)
response.write(lsb2.selecteditem.text)
end sub
<form name="form1" runat="server" method="post" action="">
<asp:listbox ID="lsb1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="lsb1hdl" Rows="1" SelectionMode="single">
</asp:listbox>
<asp:listbox ID="lsb2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="lsb2hdl" Rows="1" SelectionMode="single">
</asp:listbox>
|