With this controller method: -
[AcceptVerbs(HttpVerbs.Post)]
public ViewResult Contact(Contact contactMessage)
{
return View();
}
Why does this work...
public class Contact
{
public string Name { get; set; }
public string Email { get; set; }
public string Message { get; set; }
}
<% using(Html.BeginForm()) { %>
<p>Name : <%= Html.TextBox("Name")%></p>
<p>Email : <%= Html.TextBox("Email")%></p>
<p>Message : <%= Html.TextBox("Message")%></p>
<p><input type="submit" value="Send Data" /></p>
But this doesn't?
public class Contact
{
public string ContactName { get; set; }
public string ContactEmail { get; set; }
public string ContactMessage { get; set; }
}
<p>Name : <%= Html.TextBox("ContactName")%></p>
<p>Email : <%= Html.TextBox("ContactEmail")%></p>
<p>Message : <%= Html.TextBox("ContactMessage")%></p>
<p><input type="submit" value="Send Data" /></p>
Please don't tell me that field names are only partially identified ?
Trust me - All I did was add the text "Contact" to each of the fields in the object and each of the fields in the form. Its almost as if MVC got confused with the fields all starting with the same first 7 characters.
What gives ?
Can anyone shed any light on this ?
Paul.