Suraj Shrestha
Suraj Shrestha

Reputation: 1808

creating control array in razor

How to create control array in razor or asp.net-mvc3?

enter image description here

Upvotes: 1

Views: 628

Answers (2)

Bijay Thapa
Bijay Thapa

Reputation: 380

var j=0;
$('input[type=text]').each(function (e) {
  $(this).addClass('txt_' + j)
  j++;
}

You can add class dynamically for each textbox. j is the number of textbox.

Upvotes: 1

karaxuna
karaxuna

Reputation: 26930

If you need input array you can do this:

@model List<mymodel>

for(int i = 0; i < Model.Count; i++)
{
    @Html.EditorFor(model => model[i].SomeProperty)
}

Upvotes: 0

Related Questions