开发者

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

开发者 https://www.devze.com 2023-04-12 17:36 出处:网络
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

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号