protected void buy_Click(object sender, EventArgs e) { Button buyclick = ((Button)sender); String id = buyclick.Attributes["data-id"]; if (!String.IsNullOrEmpty(id)) { Cart obj = new Cart(); obj.addSItemToCart(id); } Response.Redirect("MyCart.aspx"); }
protected void Addtocart_Click(object sender, EventArgs e) { Button addtocartbutton = ((Button)sender); String id = addtocartbutton.Attributes["data-id"]; if (!String.IsNullOrEmpty(id)) { Cart obj = new Cart(); obj.addSItemToCart(id); } String sb = @"<script>alert('Item Added to Cart');</script>"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "script", sb, false); }