简体   繁体   English

使用Request []获取HTML元素属性值

[英]Get HTML element attribute value using Request[]

I have a page where many postback clicks are there. 我的页面上有许多回发点击。 In this page many input elements there, which values are i am geting from server side using Request[]. 在此页面中,有许多输入元素,我使用Request []从服务器端获取了哪些值。 like below 像下面

.aspx .aspx

<input id="txtRefTypeCtrlType_3" name="txtRefTypeCtrlType_3" lastvalue="4" CTRLtype="4" style="display: none;">

.cs .cs

string strCTRLtype = Request["txtRefTypeCtrlType_3"];

now i have a scenario, where i need to get the CTRLtype attribute value. 现在我有一个方案,我需要获取CTRLtype属性值。 Can we get the attribute value using Request[] or something else. 我们可以使用Request []或其他方法获取属性值吗?

Please advise. 请指教。

Thanks. 谢谢。

No, you can't get the attribute value on the server side because it isn't posted. 不,您无法在服务器端获取属性值,因为该属性值未发布。 The only real way of achieving this is to create a hidden field with the attribute value and use that: 实现此目的的唯一真正方法是使用属性值创建一个隐藏字段并使用该字段:

<input type="hidden" name="ctrlType_3" value="4" />

Codebehind: 代码背后:

string attrValue = Request["ctrlType_3"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM