Helllo Elissa,
I tried your suggestion but still it does not work.
Actually, all the server controls are not working. I wrote other code
with server controls and yet nothing is displayed.
It seems as if the code only processes the HTML and not the C#...
any ideas?
Thanks,
> Ben,
The book is wrong Page_Load must have the following 2
arguments
void Page_Load(Object sender, EventArgs e)
Once you put that in the code will work.
Elissa
--- Ben Sanchez <eljami@h...> wrote:
> Hello List!
>
> I was doing one of the Try it Out examples on CH 3
> page 110 from the book
> beginning asp.net 1.0 with c# but I can't make it
> work. I downloaded the
> code from wrox but it still will not work.
>
> it supposed to display the selected item on a label
> but it does not...
>
> anybody know what is the problem?
>
> Thanks,
>
> Ben
> <script runat="server" language="C#">
> void Page_Load()
> {
> string msg = "You have selected: <br />";
> if (list1.Items[0].Selected) {
> msg = msg + list1.Items[0].Text + "<br />";
> }
> if (list1.Items[1].Selected) {
> msg=msg + list1.Items[1].Text + "<br />";
> }
> if (list1.Items[2].Selected){
> msg=msg + list1.Items[2].Text + "<br />";
> }
> Message.Text=msg;
> }
> </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:listbox id="list1" runat="server"
> selectionmode="multiple">
> <asp:ListItem>Madrid</asp:ListItem>
> <asp:ListItem>Oslo</asp:ListItem>
> <asp:ListItem>Lisbon</asp:ListItem>
> </asp:listbox>
> <br /><br /><br /><br />
> <input type="Submit">
> </form>
> </body>
> </html>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com