c# - can't get index to work with html razor -
i having major problems indexing html on partial view. model i'm using:
[display(resourcetype = typeof(myresources), name = "edittravelviewmodel_timeofdeparture")] [required(errormessage = "{0} måste fyllas i")] public string timeofdeparture { get; set; } [display(resourcetype = typeof(myresources), name = "edittravelviewmodel_dateofdeparture")] [required(errormessage = "{0} måste fyllas i")] public string dateofdeparture { get; set; }
and code partial:
<li class="clearfix"> @*use http://trentrichardson.com/examples/timepicker/*@ @html.textboxfor(model => model.dateofdeparture, new { @placeholder = myresources.shared_travelpartial_traveldate, @class = "startdate datepicker", @readonly = "readonly", @style ="width: 90px;" }); @html.textboxfor(model => model.timeofdeparture, new { @placeholder = myresources.shared_travelpartial_traveltime, @class ="startdate", @style = "width: 50px; margin-left: 15px;" }) </li>
i creating travel , first time when go through partial renderd html looks this:
<input style="width: 90px;" class="startdate datepicker hasdatepicker valid" data-val="true" data-val-required="datum f&#246;r avresa m&#229;ste fyllas i" id="listedittravelmodel_0__dateofdeparture" name="listedittravelmodel[0].dateofdeparture" placeholder="avresedatum" readonly="readonly" type="text" value="2014-03-24"> <input style="width: 50px; margin-left: 15px;" class="startdate valid" data-val="true" data-val-required="tid f&#246;r avresa m&#229;ste fyllas i" id="listedittravelmodel_0__timeofdeparture" name="listedittravelmodel[0].timeofdeparture" placeholder="avr.tid" type="text" value="08:00">
where can se got listedittravelmodel_0__
before id , name. second time goes through view same model , renders this:
<input style="width: 90px;" class="startdate datepicker hasdatepicker valid" id="listedittravelmodel_1__dateofdeparture" name="listedittravelmodel[1].dateofdeparture" placeholder="avresedatum" readonly="readonly" type="text" value="2014-03-26"> <input style="width: 50px; margin-left: 15px;" class="startdate valid" id="timeofdeparture" name="timeofdeparture" placeholder="avr.tid" type="text" value="12:32">
now first input got correct id , name second input didn't listedittravelmodel_1__
before id
, name. why happening?
Comments
Post a Comment