Mega Code Archive

 
Categories / ASP.Net Tutorial / ASP Net Controls
 

Set array value to asp

<script runat="server">    sub Page_Load(Sender as Object, e as EventArgs)       if not Page.IsPostBack then          dim arrColors() as string = {"red", "orange", "yellow", "green", "blue", "indigo", "violet"}          lbColors.SelectedIndex = 0          lbColors.DataSource = arrColors       end if       DataBind()    end sub </script> <html><body>    <form runat="server">       <asp:Listbox runat="server" id="lbColors"          width="150"          AutoPostBack="true"          SelectionMode="Single" >       </asp:Listbox>           <asp:Label id="lblMessage" runat="server"          Text='<%# lbColors.SelectedItem.Text %>' />    </form> </body></html>