Imagine my surprise when playing around with the recently released ASP.NET MVC Preview2 bits, and finding that one of my hidden form fields wasn't being mapped on the server because the form field only included an id attribute - and not a name attribute.
In other words, I had rendered markup that looked like this:
<input id="objectId" type="hidden" value="3">
When I really needed this:
<input id="objectId" name="objectId" type="hidden" value="3">
But, that threw me for a bit of a loop. See, I've been spending so much time playing around with client-side stuff (i.e. the DOM) for so many years now that I had begun to think that name didn't mean anything anymore.
In fact, the W3C has effectively depricated the name attribute for HTML/DOM interaction. This I knew. But that was only part of the problem. Because the W3C still favors the name attribute for HTTP interactions. So, with POSTed forms, you'll want to make sure you use id and name attributes if you plan on doing client side interactions.
At any rate, I found all of this a bit ironic because years ago much of my markup ONLY used the name attribute. Somehow between then and now I managed to forget all of that. So, I'm just glad to see that you can teach this old dog new tricks - even if the old dog is old enough to have forgotten that he knew the tricks once before...
Comments