May 7, 2012

ASP.NET MVC - Including hidden fields in Form Submit (POST)

We can include some hidden fields in the form as the parameters. Most of the time, it is to avoid using query string (which can results in too long URL).

However, do not forget the attributes “name” for those hidden fields, otherwise they will not be include in form submission.

For e.g:

<form id=”frm1” action=”/actionHandler” method=”post”>
    <input type=”hidden” id=”hdnValue1” name=”hdnValue1” >

I encountered it and spend almost an hour to find out why. Just to share it.

No comments:

Post a Comment