albert albert

albert albert

  • NA
  • 524
  • 0

Extension method, strange ouput

May 21 2012 8:45 AM
I have an extension method:

[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 x1 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,

                tuesday = x.weekStart.AddDays(3),
                weekFinish = x.weekStart.AddDays(6)
            }).SkipWhile(x => x.weekFinish < janFirst.AddDays(1)))
            {
                j++;
                yield return new SelectListItem
                {
                    Text = new
                    {
                        maandag = firstWeek.AddDays(j * 7).ToShortDateString()
                        //Dindsdag = x1.weekStart.AddDays(1).ToShortDateString(),
                        //vrijdag = x1.weekStart.AddDays(6).ToShortDateString(),
                        //weekNum = j + 1
                    }.ToString(),

                   
                    //Value = (j + 1).ToString(CultureInfo.InvariantCulture)

                 
                };

               

               
            }

            //return helper.DropDownList()
        }//end method

[/code]

And an other method:

[code]
public static  MvcHtmlString StateDropDown(this HtmlHelper helper)
        {
            return MvcHtmlString.Create(GetWeekNumbers(helper).ToString());

        }

[/code]

And for the view I have :

[code]
<td>
                    <div class="editor-label">
                       @Html.LabelFor(model => model.Tuesday, "Dinsdag")
                    </div>
                    <div class="editor-field">
                        @Html.TextBox("Hallo", Html.StateDropDown())
                        @Html.ValidationMessageFor(model => model.Tuesday)
                    </div>
                </td>

[/code]

but I get in the texbox strange output:

ManyToMany.Helpers.DateTimeExtensions+<GetWeekNumbers>d__8

THX





Answers (1)