changing value of dropdownlist in label
Hi everybody,
I have this:
[code]
public static IEnumerable<SelectListItem> GetWeekNumbers(this HtmlHelper helper /*Dictionary<int, DateTime> dayOfWeek*/ /*,DateTime allWeeks*/ /*int selectID*/)
{
var janFirst = new DateTime(DateTime.Today.Year, 1, 1);
//beware different cultures.
var firstWeek = janFirst.AddDays(1 - (int)(janFirst.DayOfWeek));
int j = -1;
foreach (var weekNumber in Enumerable.Range(0, 52).Select(i => new
{
weekStart = firstWeek.AddDays(i * 7),
//Tuesday = firstWeek.AddDays(i * 3)
}).TakeWhile(x => x.weekStart.Year <= janFirst.Year).Select(x => new
{
x.weekStart,
weekFinish = x.weekStart.AddDays(6)
}).SkipWhile(x => x.weekFinish < janFirst.AddDays(1)))
{
j++;
yield return new SelectListItem
{
Value = string.Join(",",new string[]
{
weekNumber.weekStart.ToShortDateString(),
weekNumber.weekStart.AddDays(1).ToShortDateString(),
weekNumber.weekStart.AddDays(2).ToShortDateString(),
weekNumber.weekStart.AddDays(3).ToShortDateString(),
weekNumber.weekStart.AddDays(4).ToShortDateString(),
weekNumber.weekStart.AddDays(5).ToShortDateString(),
weekNumber.weekStart.AddDays(6).ToShortDateString(),
}),
Text = (j + 1).ToString(CultureInfo.InvariantCulture)
};
}
}//end method
[/code]
and for the view:
[code]
<td>
<div class="editor-field">
@Html.Label("txtBox", Model.Monday.ToLongDateString())
@Html.ValidationMessageFor(model => model.Monday)
</div>
</td>
[/code]
and the JQuery:
[code]
function Selectedchange() {
$("#txtBox").val($("#weekId").val().toString().split(",") [0]);
}
[/code]
but the selected value doesnt change in the label.
But If I do a textBox, like this:
[code]
</div>
<div class="editor-field">
@Html.TextBox("txtBox", Model.Monday.ToLongDateString())
@Html.ValidationMessageFor(model => model.Monday)
</div>
[/code]
then the value change.
But how to manage it in the html.Helper: Label?
THX for helping.