The following code is in the /Courses/Detail action:
[AcceptVerbs("GET")]
public ActionResult Detail(int id)
{
ViewData["Title"] = "A View Title";
return View(tmdc.GetCourseById(id));
}
The tmdc.GetCourseById(id) method returns an instance of type "Course" for the View. In the View I am using <%= HTML.TextBox("Title")%> to display the value of the Title property for the Course object. Instead the text box is displaying the string A View Title. Is this normal/expected behavior? What would be the best way to handle this?
Update
As a workaround, I've changed ViewData["Title"] to ViewData["VIEW_TITLE"]...but would like a cleaner way to handle this collision...or to know if this is an expected result.
Better Way of Handling This
Thanks for your help Kevin. I used your answer as a guide and it worked:
<%= Html.TextBox("Title", ((Courses.Course)ViewData.Model).Title)%>
This is much less ambiguous than the first method I was using!