im using asp.net mvc my viewbag message not working can someone help me.
else
{
var order = new Order
{
ClientId = model.ClientId,
StateId = model.StateId,
CityId = model.CityId,
TownId = model.TownId,
Postcode = model.Postcode,
Address = model.Address,
DatePosted = DateTime.Now,
DeliveryDate = Convert.ToDateTime(model.DeliveryDate),
Quantity = model.Quantity,
Status = "Lined-up",
DateDelivered = null,
Notes = model.Notes ?? ""
};
_orderService.Add(order);
ViewBag.Message = "Your order successfully inserted";
return RedirectToAction("add");
}
My script
@if (ViewBag.Message != null)
{
window.onload = function () {
alert("@ViewBag.Message");
};
}

Faisal PathanRank #291 · 8.6K reputationPosted Aug 10, 2019, 1:37 AM EDT
Faisal PathanRank #291 · 8.6K reputationPosted Aug 9, 2019, 10:27 PM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 9, 2019, 11:35 PM EDT
Faisal Pathan
Faisal PathanRank #291 · 8.6K reputationPosted Aug 9, 2019, 11:41 PM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 9, 2019, 11:45 PM EDT
Faisal Pathan
Faisal PathanRank #291 · 8.6K reputationPosted Aug 10, 2019, 12:08 AM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 10, 2019, 12:25 AM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 10, 2019, 12:36 AM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 11, 2019, 4:48 PM EDT
Faisal Pathan
still the same when i click the page they show first.Tamal MarickRank #4,584 · 336 reputationPosted Aug 12, 2019, 2:46 AM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 12, 2019, 5:12 PM EDT
Denmark PusoRank #7,130 · 248 reputationPosted Aug 12, 2019, 5:47 PM EDT