<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="varCookies.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<%
if(Name.Text!="")
{
HttpCookie MyCookie = new HttpCookie("Name");
MyCookie.Values["Name"] = Name.Text;
//MyCookie.Expires = ;
Response.Cookies.Add(MyCookie);
}
%>
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="Name" style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP: 128px" runat="server"
Width="336px"></asp:TextBox>
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 96px" runat="server"
Width="312px" Height="24px">Enter your name :</asp:Label>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 144px; POSITION: absolute; TOP: 192px" runat="server"
Width="240px" Text="Submit"></asp:Button>
</form>
</body>
</HTML>
[.net] Storing page variables into cookies ...yammy!!
Hi !
I am trying to store all page variables into cookies ...something like every page with its own cookie in C# ASP.NET.... Here's what i tried to do :
I have an input box (id=Name) and i try to save the value into a cookie if this input box is not empty ...see below ....Now ...the thing i don't know is ...how do i reference data from cookie when i refresh my page.....?
THX!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement