• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

How to populate up the listbox control, aqquire the user selection and navigate to the appropriate page?

Hi Guru's
I'm still new to asp.net and quite frankly confuses me with its at server vs at client terminology.
I need to populate a list box with three items:

Menu Choice 1
Menu Choice 2
Menu Choice 3

I then need the following to happen:
I need my user to click on an item and then press the OK button
the VB code picks up the selection and then navigates to the appropriate webpage:
Page1.aspx, Page2.aspx, Page3.aspx

My Question:  How to populate up the listbox control, aqquire the user selection and navigate to the appropriate page?

Thank you all!

Ted
0
tcalbaz
Asked:
tcalbaz
  • 2
1 Solution
 
b1xml2Commented:
<%@ Page Language="vb"%>
<script language="VB" runat="server">
Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs)
      If Not IsPostBack Then
            Dim values As String() = New String() {"Page1.aspx","Page2.aspx","Page3.aspx"}
            MenuItems.DataSource = values
            MenuItems.DataBind()
      End If
End Sub

Sub MenuItems_SelectedIndexChanged(ByVal sender As Object,ByVal e As EventArgs)
      Response.Redirect(MenuItems.SelectedValue,True)
End Sub
</script>
<html>
<head><title>Menu Items</title></head>
<body>
<form runat="server">
<asp:ListBox Id="MenuItems" runat="server" AutoPostBack="True" OnSelectedIndexChanged="MenuItems_SelectedIndexChanged"></asp:ListBox>
</form>
</body>
</html>
0
 
tcalbazAuthor Commented:
b1xml2

Bingo!
Thanks for the quick response!

Ted
0
 
b1xml2Commented:
no problems =)
0
 
vadivhereCommented:
http://www.developerfusion.com/show/3828/7/

Checkout this code....

Cheers!!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now