如何读取输入的名字从Request.Form集合输入值 [英] How to read input value from the Request.Form collection by input name

查看:299
本文介绍了如何读取输入的名字从Request.Form集合输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够的HtmlHiddenField从上回发一个用户控件Request.Form集合控制来读取值。集合中的按键似乎重新present控件的名称属性,而不是ID。我可以使用新的ClientIDMode属性时,我的用户控件不同的命名容器中放置在不同的页面从而有助于控制ID。但是,我该怎么办的name属性一样吗?该HtmlHiddenField.Name属性不Reqest [关键]对象时,在命名控制匹配键名。

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.

推荐答案

您必须使用的唯一ID 像控制财产低于

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

这篇关于如何读取输入的名字从Request.Form集合输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆