Ég var að velta því fyrir mér hvort einhver gæti sagt mér villuna með þessa sáraeinföldu ASP vefsíðu.
<%@ Page Language=“c#” %>
<script Language=“c#” runat=“server”>
void Page_Load(object source, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now);
if(!(IsPostBack))
{
MyButton.Text = “Vista”;
MyDropDownList.Items.Add(“Blue”);
MyDropDownList.Items.Add(“Red”);
MyDropDownList.Items.Add(“Gray”);
}
}
public void Click(object sender, EventArgs e)
{
HttpCookie MyCookie = new HttpCookie(“Background”);
MyCookie.Value = MyDropDownList.SelectedItem.Text;
Response.Cookies.Add(MyCookie);
HttpCookie MinKaka = new HttpCookie(“Nafnid”);
MinKaka.Value = Nafn.Text;
Response.Cookies.Add(MinKaka);
}
string GetBackground()
{
return Request.Cookies["Background"].Value;
}
string nafnidhans()
{
return Request.Cookies["Nafnid"].Value;
}
</script>
<html>
<% if(Request.Cookies["Background"] != null)
{ %>
<body bgcolor=“<% Response.Write(GetBackground()); %>”>
<br/>
<br/>
<br/>
<h1> Velkominn aftur “<% Response.Write(nafnidhans()); %> ” <h1/>
%<}
else
{%>
<body>
<form id=“CookieForm” method=“post” runat=“server”>
Veldu þinn uppáhaldslit =
<asp:DropDownList id=MyDropDownList runat=“server”/>
Hvad Heitir Þú? = <asp:textbox id=“Nafn” runat=“server”/>
<asp:button id=MyButton runat=“server” OnClick=“Click”/>
<%} %>
</form>
</body>
</html