how to add loading bar on blow mention code
protected void btnAddToCart_Click(object sender, EventArgs e)
{
//lblMessage.Text = "Hi";
//Response.Write("<script>alert('Hi');</script>");
if (Session["CustomerID"] == null)
{
//lblMessage.CssClass = "alert alert-danger";
//lblMessage.Text = "Please Login first then add products!";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "SweetAlert", "swal('Oops!', 'Please Login first then add products!', 'warning');", true);
Response.Redirect("~/Login");
return;
}
Int64 _selectedPID = Convert.ToInt64((sender as Button).CommandArgument);
_CustomerID = Session["CustomerID"].ToString();
Int64 Id = 0;
string _action = "INSERT";
foreach (DataListItem items in this.DataList1.Items)
{
Int64 _productId = Convert.ToInt64((items.FindControl("Lbl_ProductID") as Label).Text);
string _productName = (items.FindControl("LblProudctName") as Label).Text;
string _productPrice = (items.FindControl("lblproductPrice") as Label).Text;
TextBox txtQt = (items.FindControl("txtQuantity") as TextBox);
Int64 _userQty = Convert.ToInt64(txtQt.Text);
int _stockQty = Convert.ToInt32((items.FindControl("lblStockQty") as Label).Text);
if (_stockQty < _userQty)
{
//lblMessage.Text = "Enter qty of less than " + _stockQty.ToString();
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "SweetAlert", "swal('Enter Qty Less than " + _stockQty.ToString() + "');", true);
return;
}
if (_selectedPID == _productId)
{
double _price = Convert.ToDouble(_productPrice);
Int64 _qty = Convert.ToInt64(txtQt.Text);
double Amount = _price * _qty;
bool _alreadyExists = _productExists(_CustomerID, _productId);
if (_alreadyExists == true)
{
_UpdatedCart(_productId, _CustomerID, _qty);
//lblMessage.CssClass = "alert alert-danger";
//lblMessage.Text = "items Qty Updated..";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "SweetAlert", "swal('Product Qty Updated..');", true);
}
else
{
_cartFunctions(Id, _productId, _qty, _CustomerID, Amount, _action);
//lblMessage.CssClass = "alert alert-success alert-dismissable fade in";
//lblMessage.Text = "items Added Successfully..";
Label lblfff = ((Label)Master.FindControl("Lbl_CartTotalAmt") );
DataSet ds = new DataSet();
ds=GetCartPrice();
lblfff.Text = ds.Tables[0].Rows[0][0].ToString();
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "SweetAlert", "swal('Product Added Successfully..');", true);
}
}
}
}