views:

96

answers:

1

For reasons currently unknown, in a strongly typed partial view that handles editing which was created using the auto-scaffold for an "Edit" template, refuses to display any data in the textbox.

But, the test titletext string displays the relevent content.

<% using (Html.BeginForm()) {

try
{
%>

<fieldset>
<legend>Fields</legend>

<p>

<% 
string titletext = Model.Title.ToString();
%>

<%= titletext %>

<label for="Title">Title:</label>
<%= Html.TextBox("Title", Model.Title) %>
<%= Html.ValidationMessage("Title", "*") %>

</p>
A: 

Make sure the text you put into the textbox doesn't contain html tags - try to html.encode your text.

In MVC 2 this is handled automagically.

Edit: Isn't the Model.Title property in conflict with Page-level Title variable?

twk
Tried <%= Html.TextBox("Title", Html.Encode(Model.Title)) %> and it remains empty. BTW the Title contains purely text.
Nicholas Murray
Isn't the Model.Title property in conflict with Page-level Title variable? - Not sure what you mean?
Nicholas Murray
Try to name differently the Title property of the Model. Just try MyTitle for example. In asp.net mvc some names are defined by convention, might be a conflict there.
twk
There are other property names such as Model.Detail that aren't displaying in the Edit text boxes which display fine elsewhere.
Nicholas Murray
It is interesting that someone downvote my try to help, but no other answer was added. :(
twk
Just a driveby critic!
Nicholas Murray