Quantcast
Viewing latest article 25
Browse Latest Browse All 37

Answer by David Silva-Barrera for How can i set the html id attribute in razor

I just tested this solution with MVC5 .net 4.5.1. I was trying to set manually the form Id because I was going to have several forms in the same page and I needed to control then separatelly with JS :

@using (Ajax.BeginForm("Edit", "Products", null, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divEmp"+Model.Id }, htmlAttributes : new { id = "form_"+ Model.Id } )){}

Enfasis in last parameter: htmlAttributes : new { id = "form_"+ Model.Id }

It is the same with @Html.BeginForm() and other helpers.

The htmlAttributes: part is not really necessary.


Viewing latest article 25
Browse Latest Browse All 37

Trending Articles