views:

16

answers:

2

Hi,

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 and why doesn't it show the Name of the day of the week and shows the integer value instead?

A: 

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...

Justin Wignall
+1  A: 

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.

Mattias Jakobsson
Overlooked this, there is a Model.JourneyBooking.DayOfWeek field which is obviously being shown. Thanks man.
Fermin