In my forum project I have a partial view (.ascx) that is used for adding a new forum post. Forum posts live inside Topics (Categories) and both these tables have a column named Title.
Now the problem is that when I place the partial view on a Topic page, it automatically grabs the Title value from the Topic, thus populating my Title Textbox with the Topic Title. Not ideal!
The code inside the CreatePost.ascx is simply
<label for="Title">Title</label>
<%= Html.TextBox("Title") %>
I’ve tried changing that to <%= Html.TextBox("Post.Title") %> but then the Textbox value doesn’t get posted.
Is this normal behaviour, and is there a way I can get rid of it without clearing it with Javascript?
I’ve even tried setting a value using the 2nd overload Html.TextBox("Title", "some value") but that just gets overridden.
Please help!
If you are using ASP.NET MVC 2 you should always use strongly typed helpers which will correctly handle binding: