我有<asp:HiddenField ID="hiddenListFiled" runat="server" Value="" />
在我的 .aspx 页面中,我在其中包含 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的值。但它给了我“hiddenListFiled”未定义。
所以我尝试在 Multifile.js 本身中 createElement of type=hidden 并尝试读取它说我的元素未找到。
您能否建议我如何获取代码后面隐藏文件的值?我已经尝试过Request.Form["hiddenListFiled"]
运气不好。
最佳答案
您可以设置 ClientIDMode Property的值设置为 Static,以便 ASP.Net 不会重命名它:
<asp:HiddenField ID="hiddenListFiled" ClientIDMode="Static" runat="server" Value="" />
关于javascript - 读取后面代码中的hiddenFile值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46933835/