hi
I have 2page 1-member.aspx 2-city.aspx
in both page are 2 checkboxs and 1 button and 1 lable:
member.aspx
<asp:label id="message" runat="server" />
<div>
<asp:CheckBox ID="Chsex" runat="server" Text="female" />
<asp:CheckBox ID="Chage" runat="server" Text="30" />
</div>
<asp:ImageButton ID="Imgregister" runat="server" OnClick="Imgregister_Click" />
and city.aspx page:
<asp:label id="message" runat="server" />
<div>
<asp:CheckBox ID="Chcountry" runat="server" Text="Itally" />
<asp:CheckBox ID="Chcity" runat="server" Text="Rome" />
</div>
<asp:ImageButton ID="Imgregister" runat="server" OnClick="Imgregister_Click" />
here when users checked checkboxs it will save checkboxs text in cookie and shows these text into label(id=message) I wrote below code for
member.aspx
protected void Page_Load(object sender, EventArgs e)
{ if (Request.Cookies["register"] != null)
{
string user;
user = Request.Cookies["register"]["sex"];
user = user + " " + Request.Cookies["register"]["age"];
user = user + " " + Request.Cookies["register"]["country"];
user = user + " " + Request.Cookies["register"]["city"];
message.Text = user;
}
else {
message.Text = "no cookie";
}
}
protected void Imgregister_Click(object sender, ImageClickEventArgs e)
{
if (Chsex.Checked)
{
Response.Cookies["register"]["sex"] = Chsex.Text;
}
if (Chage.Checked)
{
Response.Cookies["register"]["age"] = Chage.Text;
}
GetUsersInfo();
}
string GetUsersInfo()
{
string user;
user = Request.Cookies["register"]["sex"];
user = user + " " + Request.Cookies["register"]["age"];
user = user + " " + Request.Cookies["register"]["country"];
user = user + " " + Request.Cookies["register"]["city"];
message.Text = user;
return Request.Cookies["register"].Value;
}
and for city.aspx
protected void Page_Load(object sender, EventArgs e)
{ if (Request.Cookies["register"] != null)
{
string user;
user = Request.Cookies["register"]["sex"];
user = user + " " + Request.Cookies["register"]["age"];
user = user + " " + Request.Cookies["register"]["country"];
user = user + " " + Request.Cookies["register"]["city"];
message.Text = user;
}
else {
message.Text = "no cookie";
}
}
protected void Imgregister_Click(object sender, ImageClickEventArgs e)
{
if (Chcountry.Checked)
{
Response.Cookies["register"]["country"] = Chcountry.Text;
}
if (Chcity.Checked)
{
Response.Cookies["register"]["city"] = Chcity.Text;
}
GetUsersInfo();
}
string GetUsersInfo()
{
string user;
user = Request.Cookies["register"]["sex"];
user = user + " " + Request.Cookies["register"]["age"];
user = user + " " + Request.Cookies["register"]["country"];
user = user + " " + Request.Cookies["register"]["city"];
message.Text = user;
return Request.Cookies["register"].Value;
}
now problem is that when I click on button to create cookie it delete previouse cookie I mean:
when I checked chesex and chage in member.aspx it will shows (Female 30 ) in label
and after that when I run city.aspx page and checked chcountry and chcity and click on button it will show (Itally Rome) but I want it shows(Female 30 Itally Rome) becuse before I create cookie in member.aspx page with value (Femal 30) and I want it shows these values in city.aspx page...
in two pages when I click button it delete cookies that I create in other page...
where is problem
Please help me
Best Regards
Neda