c# - ASP.NET MVC4 - Multiple add in multiple textboxes -



c# - ASP.NET MVC4 - Multiple add in multiple textboxes -

i'm working asp.net mvc4. want offer possibility add together multiples records (from 1 3 maximum) displaying view multiple textboxes represents same things.

for instance, in view, have :

start hr (1) : |textboxforhours| h |textboxforminutes|

start hr (2) : |textboxforhours| h |textboxforminutes|

start hr (3) : |textboxforhours| h |textboxforminutes|

in controller, i'll check how many textboxes have been filled , save in db.

here's viewmodel i've created :

public class deniedintervalsviewmodel { public int starthour { get; set; } public int startminute { get; set; } }

any thought that?

you can utilize input naming convention array, list, collection or dictionary this

[updates]

oneway inputs:

@for (int = 0; < model.count; i++) { <div> <label>start hr :</label> <input type="text" name="intervals[@i].starthour " value="" /> <input type="text" name="intervals[@i].startminute " value="" /> </div> }

to bind viewmodel view:

@for (int = 0; < model.count; i++) { <div> <label>start hr :</label> @html.textboxfor(model => model.intervals[i].firstname) @html.textboxfor(model => model.intervals[i].lastname) </div> }

and parent viewmodel contains array

public class theviewmodel{ public deniedintervalsviewmodel[] intervals{ get; set; } } public class thecontroller{ public actionresult blah(deniedintervalsviewmodel[] intervals) { // ... } }

c# asp.net-mvc asp.net-mvc-4 post

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -