1

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

enter image description here

1
  • What exactly are you trying to do? "Controls" in the traditional sense don't exist in mvc. Please provide more information so we can help. Commented Aug 16, 2012 at 9:35

2 Answers 2

1
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.

Sign up to request clarification or add additional context in comments.

Comments

0

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)
}

3 Comments

i want to count how many textboxes are there in the view and give them an id automatically..
I don't understand what you mean. Please explain better or provide some code
i've posted the image above.. i want to create like that.. but i don't know how many textboxes will be there in my view.. i don't want to use editor templates..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.