62,254
社区成员
发帖
与我相关
我的任务
分享
int[] aq = new int[10];
for (int sz = 1; sz <=5; sz++)
{
if (Label2.Text == sz.ToString())
{
HttpCookie cookie = new HttpCookie(aq[sz].ToString());
if (RadioButton1.Checked == true) { cookie.Value = "A"; }
if (RadioButton2.Checked == true) { cookie.Value = "B"; }
if (RadioButton3.Checked == true) { cookie.Value = "C"; }
if (RadioButton4.Checked == true) { cookie.Value = "D"; }
if (RadioButton5.Checked == true) { cookie.Value = "E"; }
cookie.Expires = DateTime.Now.AddMinutes(20);
Response.Cookies.Add(cookie);
HttpCookieCollection cookies;
cookies = Request.Cookies;
string[] num = new string[5];
//for (int i = 1; i < num; i++)
for (int i = 1; i <= num.Length; i++)
{
HttpCookie abc = new HttpCookie("num"+i.ToString ());
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0, 0, 1, 0, 0); //过期时间为1分钟
abc.Expires = dt.Add(ts);
if (RadioButton1.Checked == true)
{ abc.Values.Add("num" + i.ToString(), "A"); }
if (RadioButton2.Checked == true)
{ abc.Values.Add("num" + i.ToString(), "B"); }
if (RadioButton3.Checked == true)
{ abc.Values.Add("num" + i.ToString(), "C"); }
if (RadioButton4.Checked == true)
{ abc.Values.Add("num" + i.ToString(), "D"); }
if (RadioButton5.Checked == true)
{ abc.Values.Add("num" + i.ToString(), "E"); }
Response.Cookies.Add(abc);
HttpCookie ba = Request.Cookies["num" + i.ToString()];
}
for (int a = 1; a <= Convert.ToInt32(Label2.Text); a++)
{
Response.Write(Request.Cookies["num"+a.ToString()].Value);
}