Mega Code Archive

 
Categories / ASP.Net / Asp Control
 

Get selected item from asp

<script runat="server" language="C#">   void Page_Load()     {       if (Page.IsPostBack) {              Message.Text = "You have selected " + list1.SelectedItem.Value;       }     } </script> <html>   <head>     <title>Drop Down List Example</title>   </head>   <body>     <asp:label id="Message" runat="server"/>      <br />     <form runat="server">     Which city do you wish to look at hotels for?<br /><br />     <asp:dropdownlist id="list1" runat="server">       <asp:listitem>Madrid</asp:listitem>       <asp:listitem>Oslo</asp:listitem>       <asp:listitem>Lisbon</asp:listitem>     </asp:dropdownlist>     <br /><br /><br /><br />     <input type="Submit">     </form>   </body> </html>