Search code examples
c#asp.net-mvcasp.net-mvc-4html.textboxfor

how to write multiple lambda values together with Html.TextBoxFor


I try to display birthdate like 22.10.1984 using textboxfor in MVC but I couldnt figure out how to put that together?

 @Html.TextBoxFor(model => model.DateOfBirthDay + "." + model => model.DateOfBirthYear + "." + model => model.DateOfBirthYear)

Solution

  • If you don't want to change your model as suggested in the comments, you could just do this:

    @Html.TextBoxFor(model => string.Format("{0}.{1}.{2}", model.DateOfBirthDay, model.DateOfBirthMonth, model.DateOfBirthYear))