-1

I want data from Iformcollection in nopCommerce 4.0 it getting null value.

This is my post method in controller

[HttpPost]
public ActionResult UpdateCart(int Id, IFormCollection form)
{
  var setting = settingService.LoadSetting<DemoSetting>(_storeContext.CurrentStore.Id);

  //Check plugin is enabled or not
  if (!_setting.DemoSettingEnabled)
      return Content("");

  //Check null value
  if Id,<= 0)
    throw new ArgumentNullException("Id,");

This is my view page from which i can post data

 <form asp-controller="DemoDiscounts" asp-action="UpdateCart" asp-antiforgery="true"
          asp-route-Id="@Model.Id" asp-route-id="product-attributes-form" > 

Can you please suggest if any one have solution?

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76

2 Answers2

2

Hey You can try this hope so it will helpful to you

<form method="post" asp-controller="YourControllerName" asp-action="YourActionName" asp-route-Id="@Model.Id" id="product-attributes-form" role="form">

Main thing you forgot Method="Post" and give id="product-attributes-form" role="form" hope so it can helpful to you

ILYAS PATEL
  • 278
  • 1
  • 12
1

You need to add role parameter in tag

i.e. role="form"

<form method="post"  role="form">

...
...
</form>
Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
Raju Paladiya
  • 778
  • 2
  • 12
  • 35