This is my controller C# code.
var timeList = new List<string>
{
"8.00 AM",
"8.15 AM",
"8.30 AM",
"8.45 AM",
"9.00 AM",
"9.15 AM",
"9.30 AM"
"17.00 PM"
};
ViewBag.TimeList = timeList;
Are there anyways to modify my above code start time from 8.00 to 17.00 with 15 mints interval with display my timeList?
This is my View model
@foreach (var T1 in ViewBag.TimeList)
{
@T1
}
I have already added my code @Value = @T1 but it is not working
@for (int i = 0; i < 3; i++)
{
@Html.EditorFor(m => m.Time, new { htmlAttributes = new { @class = "form-control myPicker", @Value = @T1 } })
<br />
<span id="mySpan-@i"></span>
}
Can anyone please tell me how do I automatically fill out web forms time with interval (eg, 8.00, 8.15..etc) when page first loading.
@Value = @T1cannot work sinceT1does not exist in the context of the loop (and in any case you should NEVER attempt to set thevalueattribute when using a HtmlHelper). What is the reason to the@for (int i = 0; i < 3; i++)loop?@for (int i = 0; i < 3; i++)loop for creating 3 identical inputs. Your code does not make any sense so its a bit hard to understand what you want the output of that loop to be. And what is the type of propertyTime?forloop for? You need to explain what you want the output to be (by editing your question).