From my page’s code-behind I want to access the value of this hidden field. The value is set properly. I confirmed by checking its value.
<div class="hiddenValues">
<input id="HiddenReportId" type="hidden" />
</div>
From my code behind, I’m using the following to access the above input
string id = Request.Form["HiddenReportId"];
When I run the application this line throws a null exception. Any suggestions ? Thanks!
The
inputneeds to be inside of theformtag (which it may be, can’t tell from the code snippet). Also, it needs to have anameattribute:Its
idattribute may be redundant and isn’t necessary if you’re not using it. But form elements are identified by theirnameattributes in a POST.(It feels a bit unintuitive from an ASP.NET perspective to the uninitiated, I know. ASP.NET convention is to identify everything by an
ID, but web browsers usenamewhen crafting a POST. And the web browser knows nothing of the server-side technology being used, it follows HTTP standards instead.)