Wayne
Wayne

Reputation: 195

ASP.NET MVC 2 Form Not Passing Values

I have a strange problem happening today. I am running the latest version of the MVC V2 framework and have been having no trouble at all - I came in this morning and for some reason values aren't being passed in to actions.

To clarify lets say I have something like this:

<% using (Html.BeginForm("Register", "Registration", FormMethod.Post)) { %>
....
<input type="submit" name="register" id="register" value="Register" />
<% } %>

And in my controller I have the following:

[HttpPost]
public ActionResult Register(RegistrationModel model, string register)
{
      // At this point the register string is null
}

This has been working fine for a while now and I have not changed anything that I can think of that would cause this to happen.

Does that make sense and as anyone any idea what is going on or what I have messed up?

Thanks.

Upvotes: 1

Views: 1197

Answers (2)

Wayne
Wayne

Reputation: 195

Turns out I really hadn't made any code changes. It was indeed the theme that I was using for the site. Long story short it came with a JavaScript file to various things and tucked away at the bottom of the file was a function to skin the buttons - once I had removed that line it worked just fine.

Upvotes: 1

John Farrell
John Farrell

Reputation: 24754

"Not changed anything", Well most of the time code doesn't work differently just because its Friday instead of Thursday.

" I can think of that would cause"

So you changed something, undo those changes one by one and see what happens.

Something must have changed. Do you have a custom model binder that you were working on? Did you add a route that may catch the one your posting too?

Upvotes: 1

Related Questions