Is there anything in MVC that is equivalent to the <Asp:Repeater> of Web Forms?

Asked

Viewed 64 times

0

I am mounting a form where some fields may or may not repeat, example:

Course 1:

  • Course [input text]
  • Institution [input text]
  • Year of completion [input text]

Course 2:

  • Course [input text]
  • Institution [input text]
  • Year of completion [input text]

Course ...(n):

In Webforms I would use a asp:repeater and would take the result by form Submit, in MVC there is something equivalent so that I can take the values inserted in these inputs dinâmicos in giving submit on the page? If it does not exist, could you show me a way.

2 answers

0


If you specify the input name so name="exemplo[]", and in the controller put like this (string[] exemplo), he will understand. Try so to see.

0

Hello @Deividson, from what I understand you have a list of courses want to put your elements in html, good for that you can be using a foreach and building its structure

@foreach(var curso in lstCursos){
  curso.Curso
  curso.Instituição
  curso.Ano conclusão
}
  • I misposed the question, the question is not imprimir in screen the values coming from the Controller, but yes, send the values inputados on screen for Controller when giving Submit. Remembering that, as a person can have 1 or several courses performed these fields are dynamic (may or may not exist) and I do not know how to assemble the object that will receive this data (I do not even know if it is possible to receive the data as I am describing). But thanks.

  • do you want to submit the form with a person object and a course list? If so, you can submit the form with ajax.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.