geetha geethaRank #7,130 · 248 reputationPosted Nov 25, 2021, 8:29 AM EST
0
Here I explain how to pass multiple parameters from ajax to MVC controller with an example and sample code.
In this example, on the button click, we using Ajax Post Method to send data to controller.
Model.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace product.Models
{
publicclass Product
{
publicint productid{ get; set; }
publicstring productname { get; set; }
publicdecimal productprice { get; set; }
}
}
Controller:
using product.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace product.Controllers
{
publicclass productcontroller : Controller
{
// GET: productcontroller
public ActionResult Index()
{
return View();
}
public JsonResult GetJsonData(Product product)
{
return Json(product);
}
}
}
Index.html:
@{
Layout = null;
}
"viewport" content="width=device-width" />
How to pass multiple parameters from ajax to mvc controller - Aspsolution.net
Sachin SinghRank #66 · 26.2K reputationPosted Oct 7, 2020, 6:08 AM EDT
{
}
geetha geethaRank #7,130 · 248 reputationPosted Nov 25, 2021, 8:29 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts