I spotted some strange behavior and wanted to see if anyone else had come across it and if I was being silly or if it was a bug.
When and ID is passed in the URL to a page along with a model wit an ID properties
The view renders out different values for Model.Id
ViewModle example
public int Id { get; set; } - value 2
....
Controller example
public ActionResult Index(int id)
{
// code
return View(model);
}
URL looks like - Activity/Index/1 - url id = 1
If I enter the following into my view
@Html.TextBoxFor( x => x.Id)
@Html.TextBoxFor(x => Model.Id)
@Html.TextAreaFor(x => Model.Id)
<p>@Model.Id</P>
I get the following output
Value of Textbox = 1
Value of TextArea = 1 but the value of the
<p>
tag = 2 - The Id I passed into the view in my ViewModel
I fixed this by renaming the Id field in my ViewModel to TableId
So it seems to me that the Id passed into the url is being used up by the Textbox / Area for and the paragraph finds the value I pass into my ViewModel. Very strange