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 differ开发者_开发百科ent 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.
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];
精彩评论