0

I would like to know how to convert the following HTML form into ASP.Net MVC Razor @Html.BeginForm. The problem is that I don't know how to inject the html form parameters like data-required-label="@Html.GetLabel("form-required-field")" or data-required-group-label="@Html.GetLabel("form-choice-makechoice")"

<form class="form"
          enctype="multipart/form-data"
          novalidate
          data-required-label="@Html.GetLabel("form-required-field")"
          data-required-group-label="@Html.GetLabel("form-choice-makechoice")"
          data-api-endpoint="/api/form"
          method="post">
  • `@Html.Form` accepts an argument for html attributes, you can use underscore in property names instead of hypen and it will [automatically change it to hypen for you](https://stackoverflow.com/questions/2897733/hyphenated-html-attributes-with-asp-net-mvc) – Mat J Feb 10 '21 at 09:47
  • @MatJ your comment solved the problem. Thanks for the support. It would be good if you change your comment into a response so I can set it as the valid answer. – Ignacio Tome Feb 10 '21 at 10:22
  • Kindly give the vote to the link in my previous comment. I'll suggest that as the duplicate for your question. Accept the prompt you get above your question about the duplicate suggestion, so that others can find the answer to your question there. – Mat J Feb 10 '21 at 11:06

0 Answers0