Problem displaying DayOfWeek in MVC 1.0
I have an ascx page which contains the following line:
<%= Html.TextBox("DayOfWeek", Model.JourneyBooking.StartDate.DayOfWeek.ToString(), new { @readonly = "readonly", style = "width:90px" })%>
This is inside an .ascx page and when display it inside a jQuery dialog popup the textbox shows '5' as the contents.
This should show Friday so as a test I added this in the line above the textbox declaration:
<%= Model.JourneyBooking.StartDate.DayOfWeek.ToString() %>
This shows 'Friday' as expected.
What is the difference between using the TextBox helper class a开发者_开发技巧nd why doesn't it show the Name of the day of the week and shows the integer value instead?
It should show what you expect. One thing, however, that can overwrite this is the post parameters. If you have a post parameter with the name "DayOfWeek" then the value of that parameter will be used instead of the value you supply. You can use firebug to check if you are not sure of your parameters.
Try using:
<%= Html.TextBox("DayOfWeek", Model.JourneyBooking.StartDate.ToString("dddd"), new { @readonly = "readonly", style = "width:90px" })%>
and see if that works. Not an answer as such I know but might help...
精彩评论