Example #1
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //thong tin
            List <thongtin> thongtin = new List <thongtin>();
            thongtin        tt;

            for (int i = 1; i <= 16; ++i)
            {
                tt          = new thongtin();
                tt.Id       = i;
                tt.Name     = "Sản phẩm" + i;
                tt.Path     = "Content/img/sp/sp" + i + ".jpg";
                tt.Describe = "Sản Phẩm Thời Trang Nữ!";
                tt.Price    = 1000000;
                thongtin.Add(tt);
            }
            Application["sanpham"] = thongtin;
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     /*if (Request.QueryString["id"] == null)
      * {
      *  Response.Redirect("trangchu.aspx", true);
      *
      * }
      * else
      * {
      *  List<thongtin> tt = (List<thongtin>)Application["sanpham"];
      *  foreach (thongtin sp in tt)
      *  {
      *      if (sp.Id.ToString() == Request.QueryString["id"])
      *      {
      *          img.ImageUrl = sp.Path;
      *          lblName.Text = sp.Name;
      *          lblDescribe.Text = sp.Describe;
      *          btnthem.CommandArgument = sp.Id.ToString();
      *      }
      *  }
      * }*/
     try
     {
         string id = Request.QueryString["id"].ToString();
         iId = Convert.ToInt32(id);
         List <thongtin> thongtin = (List <thongtin>)Application["sanpham"];
         thongtin        tt       = thongtin[iId - 1];
         img.ImageUrl            = tt.Path;
         lblName.Text            = tt.Name;
         lblDescribe.Text        = tt.Describe;
         btnthem.CommandArgument = tt.Id.ToString();
     }
     catch (Exception ex)
     {
         Response.Write("<script> alert('Chọn 1 sản phẩm để xem!');" +
                        "window.location='http://localhost:56903/trangchu';</script>");
     }
 }