I am passing productid and productprice by ajax call to the controller and want to display it to he helloPrice page via viewbag. Debugging shows that viewbag in the action method is filled by productid and productprice. but it is not redirecting the view to helloPrice page in order to show the value of viewbag on helloPrice page. Infact nothing happens.
the Action Method passiing the viewbag value to helloPrice view.
public ActionResult helloPrice(int productid,decimal Productprice)
{
String a = "produt ID id " + productid + "and priec" + Productprice;
//string a = "hi";
ViewBag.MyString = "produt ID id " + productid +"yes"+Productprice+"yes";
return View("helloPrice");
}
Ajax request passing the parameter to the controller
$.ajax({
url: '/Products/helloPrice',
data: {
//These two keys should keep consistent with the parameters ( int? ProductId , int? ProductPrice ) in action, including uppercase and lowercase.
productid: productId,
Productprice: discountAmount
},
success: function (data) {
//$('body').empty();
//$('body').append(data);
}
});