Hello,
so i've got an array of numbers that i'm posting to an asp.net mvc action that has a list(of integer) parameter and it all works great.
my question is this:
Is it safe to assume that the list(of integer) will have the numbers in the same order as they were in the array i posted?
Thanks for your time!
EDIT:
The data being posted looks like this:
POSTDATA=model.LevelIds=6&model.LevelIds=19&model.LevelIds=16&model.LevelIds=21&model.LevelIds=18
I'm using the Tamper Data firefox add on to see it.
I'm using jQuery, in traditional mode.
EDIT:
the action looks something like this:
public function Create(byval model as thecreateviewmodel) as actionresult
the thecreatviewmodel has a bunch of properties, but the interesting one is...
Public Property LevelIdsAs IList(Of Integer) = New List(Of Integer)
on the client side the view model is build with javascript/jquery:
function NewEntityDataBuilder() {
var theData = {
'model.Name' : $('#Name').val(),
'model.Description' : $('#Description').val(),
'model.LevelIds' : $('#LevelIds').val()
};
return theData;
}
that function is called from this bit of javascript which basically goes through the and adds all of the things in the list to a drop down list (select control) and selects them all.
$('#LevelIds').empty();
$('#AddedLevels').children().each(function () {
$('#LevelIds').append("<option value='" + $(this).attr('LevelId') + "'>" + $(this).attr('LevelId') + "</option>");
});
$('#LevelIds').children().attr('selected', 'selected'); //select all the options so they get posted.
var dataToPost = NewEntityDataBuilder();
this seems fairly convoluted when it's put this way, but it's actually fairly simple. it's all part of 2 connected drag and drop lists that are part of a form.
so: if i put the value of a select list with all of it's options selected in a variable and post that to an ilist(of integer) will ilist have them in the same order as they were in the select. It SEEMS like they are. but is that just a coincidence?