Hari Gillala
Hari Gillala

Reputation: 11926

Postback With Partial views-ASP.NET MVC3

I am using Jquery for displaying multiple tabs in MVC 3, based on the tutorial.Tutorial

I am loading the data for various tabs based on the partial views using the Jquery.

All the partial views are with the attribute [HttpGet]. I want to place a button in the partial view and when I click on that button it should call service and submit the data to server.

Could I do that using a partial view with attribute [HttpPost]? I tried that but it complains saying that there cannot be two methods with same Name.

are partial views does not support [HttpPost]? Am I doing something wrong?

If you have done in other way to complete these kind of task please let me know.

Thank you

Upvotes: 0

Views: 1767

Answers (1)

David Fox
David Fox

Reputation: 10753

Even though you may have attributed your Action methods with [HttpGet] and [HttpPost], they need different parameter lists. In my example below, you will need to post a string named someData in order to receive a response.

So, this is valid:

public ActionResult About()
{
    return View();
}

[HttpPost]
public ActionResult About(string someData)
{
    return View();
}

And, this is not valid:

public ActionResult About()
{
    return View();
}

[HttpPost]
public ActionResult About()
{
    return View();
}

Upvotes: 2

Related Questions