H
Halvor Nyberg
Hi,
I want to respond when the user picks another item in the
dropdownlist.
In the html section I got:
... SelectedIndexChanged="MyListChange"
(see example below)
I the script section I have the sub
sub MyListChange
MyListChange is not triggered after the Postback.
Is this logical, or have I missed something?
thanks.
<%@ Page Language="VB" %>
<script runat="server">
dim t_resp as string
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
dim i as integer
Dim myList As New ArrayList()
for i=0 to 10
myList.add("Test " & i)
next
DropDownList1.DataSource = myList
DropDownList1.DataBind()
datagrid1.DataSource = myList
datagrid1.DataBind()
else
t_resp="Post back Only"
End If
End Sub
Sub ApplyFilter_Click(Sender As Object, E As EventArgs)
t_resp= ("Apply button: " &
DropDownList1.SelectedItem.Text)
msgbox(t_resp)
end sub
public sub MyListChange(sender As Object, e As
EventArgs)
t_resp=("Dropdown Change: " &
DropDownList1.SelectedItem.Text)
end sub
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>test
</h2>
<hr size="1" />
<form id="F1" runat="server" EnableViewState="true">
<p>
Test <aspropDownList id="DropDownList1"
runat="server" SelectedIndexChanged="MyListChange"
AutoPostBack="true" EnableViewState="true"
Width="235px"></aspropDownList>
<asp:Label id="lblCur" runat="server"
forecolor="Red"> </asp:Label>
</p>
<p>
Test:
<asp:TextBox id="TextBox2"
runat="server"></asp:TextBox>
<asp:Button id="Button1"
onclick="ApplyFilter_Click" runat="server"
Text="Show"></asp:Button>
</p>
<asp:datagrid id="DataGrid1" runat="server"
EnableViewState="true" CellSpacing="1" GridLines="None"
CellPadding="3" BackColor="White" ForeColor="Black"
AutoGenerateColumns="True">
<HeaderStyle font-bold="True"
forecolor="white" backcolor="#4A3C8C"></HeaderStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
</asp:datagrid>
<%response.write(t_resp)%><%%>
</form>
</body>
</html>
I want to respond when the user picks another item in the
dropdownlist.
In the html section I got:
... SelectedIndexChanged="MyListChange"
(see example below)
I the script section I have the sub
sub MyListChange
MyListChange is not triggered after the Postback.
Is this logical, or have I missed something?
thanks.
<%@ Page Language="VB" %>
<script runat="server">
dim t_resp as string
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
dim i as integer
Dim myList As New ArrayList()
for i=0 to 10
myList.add("Test " & i)
next
DropDownList1.DataSource = myList
DropDownList1.DataBind()
datagrid1.DataSource = myList
datagrid1.DataBind()
else
t_resp="Post back Only"
End If
End Sub
Sub ApplyFilter_Click(Sender As Object, E As EventArgs)
t_resp= ("Apply button: " &
DropDownList1.SelectedItem.Text)
msgbox(t_resp)
end sub
public sub MyListChange(sender As Object, e As
EventArgs)
t_resp=("Dropdown Change: " &
DropDownList1.SelectedItem.Text)
end sub
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>test
</h2>
<hr size="1" />
<form id="F1" runat="server" EnableViewState="true">
<p>
Test <aspropDownList id="DropDownList1"
runat="server" SelectedIndexChanged="MyListChange"
AutoPostBack="true" EnableViewState="true"
Width="235px"></aspropDownList>
<asp:Label id="lblCur" runat="server"
forecolor="Red"> </asp:Label>
</p>
<p>
Test:
<asp:TextBox id="TextBox2"
runat="server"></asp:TextBox>
<asp:Button id="Button1"
onclick="ApplyFilter_Click" runat="server"
Text="Show"></asp:Button>
</p>
<asp:datagrid id="DataGrid1" runat="server"
EnableViewState="true" CellSpacing="1" GridLines="None"
CellPadding="3" BackColor="White" ForeColor="Black"
AutoGenerateColumns="True">
<HeaderStyle font-bold="True"
forecolor="white" backcolor="#4A3C8C"></HeaderStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
</asp:datagrid>
<%response.write(t_resp)%><%%>
</form>
</body>
</html>