E
Eric
Hi,
I defined a button dynamically. The button must redirect to the main menu.
First the dropdownlist1 is shown. When the user chooses a value, because
AutoPostBack=true, the procedure DropDownList1_SelectedIndexChanged is
started, creating the button dynamically.
My problem is that the button doesn't redirect to the mainmenu.aspx page,
but sends the user to the beginning of this page, showing the dropdownlist
with the chosen value but without showing the button.
Can anybody tell me why and how to fix it?
Thanks
Eric
Here the code:
aspx file:
--------
<asp:Button ID="Button1" runat="server" />
<aspropDownList ID="DropDownList1" AutoPostBack="true" runat="server">
</aspropDownList>
code-behind:
-------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
'here the dropdownlist1 is feeded with data.
end sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim bt As New Button
form1.Controls.Add(bt)
AddHandler bt.Click, AddressOf bt_Click
end sub
Protected Sub bt_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("mainmenu.aspx", False)
End Sub
I defined a button dynamically. The button must redirect to the main menu.
First the dropdownlist1 is shown. When the user chooses a value, because
AutoPostBack=true, the procedure DropDownList1_SelectedIndexChanged is
started, creating the button dynamically.
My problem is that the button doesn't redirect to the mainmenu.aspx page,
but sends the user to the beginning of this page, showing the dropdownlist
with the chosen value but without showing the button.
Can anybody tell me why and how to fix it?
Thanks
Eric
Here the code:
aspx file:
--------
<asp:Button ID="Button1" runat="server" />
<aspropDownList ID="DropDownList1" AutoPostBack="true" runat="server">
</aspropDownList>
code-behind:
-------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
'here the dropdownlist1 is feeded with data.
end sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim bt As New Button
form1.Controls.Add(bt)
AddHandler bt.Click, AddressOf bt_Click
end sub
Protected Sub bt_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("mainmenu.aspx", False)
End Sub