I am working on a Asp.net MVC 2.0 web application. In my form , i have non editable fields , so i wanted to display them as labels rather than textboxes.
I am strongly binding my model with view. So, i need to associate this label with one of the fields in model.
This is what i am trying to do:
But, it is displaying nothing..Please help
What basically i am trying to do is a add operation. i have a create view and that view has a form.
I am strongly binding this view with model.So , that i can directly associate form fields with the model Properties.
<label> Name</label> <%=Html.TextBoxFor(m=>m.name)
So, what ever i type into the textbox , it will be stored in m.name in the model.
If the text entered is "Avinash" , then m.name gives value "Avinash"
I think i am correct upto this extent:
I have a field which is readonly , the user can not change the value of it.
<label>Changed On</label> <label> DateTime.Now </label>
How to bind m.ChangedOn with the labels values(DateTme.Now)
so that it will result in m.Changedon as DateTime.now
This is what i am writing..
<td > <%=Html.LabelFor(Model=>Model.CreatedOn) %>: </td> <td> <%=Html.HiddenFor(Model=>Model.CreatedOn) %> </td>