September 18, 20091 views

Input hidden missing from post FormCollection

I futzed around trying to get my hidden selected ID to be in the FormCollection object posted to my ASP.NET MVC controller.

I could not for the life of me figure out why it was not in the collection.

The input was defined like this;

<input id="pkid" type="hidden" value="15" />

Finally after looking around I noticed it was missing the 'name' attribute.

<input id="pkid" name="pkid" type="hidden" value="15" />

After that the hidden was in the AllKeys and I could get the value, perhaps

widely known but it messed with me for a bit.

Enjoy!

1 Comments

Sign in to join the conversation

Sign in
Ben
Thanks! Ran into the same problem today and it drove me nuts...
Link