![]() |
Chapter 10 -- Using Cookies
Hi, I am trying to to run the code for Using Cookies on page 423 of Beginning ASP.NET 1.0.
Unfortunately, I am getting a an error that reads, CS1002: ; expected. However, I am not missing a semi-colon. Any thoughts on what is causing the error? Here is the code that I typed in and tried to run: <%@ Page Language="C#" %> <script Language="c#" runat="server"> void Page_Load(object source, EventArgs e) { if (!(IsPostBack)) { MyButton.Text = "Save Cookie"; My DropDownList.Items.Add("Blue"); My DropDownList.Items.Add("Red"); My DropDownList.Items.Add("Gray"); } } public void Click(object sender, EventArgs e) { HttpCookie MyCookie = new HttpCookie("Background"); MyCookie.Value = MyDropDownList.SelectedItem.Text; Response.Cookies.Add(MyCookie); } </script> <html> <body> <form id="CookieForm" methods="post" runat="server"> <asp:DropDownList id="MyDropDownList" runat="server" /> <asp:button id="MyButton" runat="server" OnClick="Click" /> </form> </body> </html> Thanks much, -Michael |
I think this is causing the error:
My DropDownList I am sure you mean: MyDropDownList right? Imar --------------------------------------- Imar Spaanjaars Everyone is unique, except for me. |
Thanks, that was problem!
I feel very silly now that I posted this in two separated forums! |
All times are GMT -4. The time now is 04:24 AM. |
Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.