How to read input value from the Request.Form collection by input name

3.5k views Asked by At

I want to be able to read values of HtmlHiddenField controls from the Request.Form collection in a user control on postback. The keys in the collection seem to represent the control's name attribute rather than ID. I can control the ID using the new ClientIDMode property which helps when my user control is placed in different pages thus within different naming containers. But how can I do the same with the name attribute? The HtmlHiddenField.Name property doesn't match the key name in Reqest[key] object when in a naming control.

I understand this is quite specific scenario because I don't have access to the hidden field control object. I am just looking for a way to control how the input name attribute is rendered as is now possible for IDs.

1

There are 1 answers

0
Deeptechtons On

You will have to access the value of the hidden field using the unique id property of the control like below

var postedValue = Request.Forms[hdnField.UniqueId];