简体   繁体   中英

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[]. like below

.aspx

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

.cs

string strCTRLtype = Request["txtRefTypeCtrlType_3"];

now i have a scenario, where i need to get the CTRLtype attribute value. Can we get the attribute value using Request[] or something else.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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