在后面的代码中读取hiddenFile值

时间:2017-10-25 13:32:14

标签: javascript asp.net vb.net

我的.aspx页面中有<asp:HiddenField ID="hiddenListFiled" runat="server" Value="" />,其中包含java脚本文件。

  <script language="javascript" src="includes/multifile.js" type="text/javascript"></script>

在我的multifile.js文件中,我将hiddenFild的值设置为

listofslected = listofslected +"///" + e.options[e.selectedIndex].text;
var listofdocts =  document.getElementById('hiddenListFiled');     listofdocts.value= listofslected  

现在,我想在代码后面读取hiddenListFiled的值。但它给了我&#34; hiddenListFiled&#34;没有定义。

所以我尝试在Multifile.js本身中创建type = hidden的元素,并尝试读取它说我找不到元素。

您能否建议我如何在代码背后获得hiddenfile的价值?我已经尝试Request.Form["hiddenListFiled"]没有运气了。

1 个答案:

答案 0 :(得分:1)

您可以将ClientIDMode Property的值设置为Static,以便ASP.Net不会重命名它:

<asp:HiddenField ID="hiddenListFiled" ClientIDMode="Static" runat="server" Value="" />