读书人

javascript中document.getElementById

发布时间: 2012-10-15 09:45:24 作者: rapoo

javascript中document.getElementById()总是返回空值
开发工具:vs2010 asp.net

希望点击提交按钮的时候检测文件类型,但是测试过程中发现返回值总是为空

代码:

<script>
function checkType() {
var fileName = document.getElementById("asfdoc");
alert(filename); return false;
}
</script>


<form id="form1" enctype="multipart/form-data" runat="server">
<div>
<p>
<span class="asfspanleft">as .doc format:</span>
<asp:FileUpload ID="asfdoc" runat="server" Width="360"/>
</p>

<p align="right">
<asp:Button ID="Button3" runat="server" Text="Submit" OnClientClick="return checkType()"
onclick="Button3_Click" />
</p>
</div>

</form>









[解决办法]
alert(document.getElementById("<%=asfdoc.ClientID %>").Value);

[解决办法]
要用asfdoc.ClientID

记得结贴
[解决办法]

探讨
谢谢啦,可是这是啥原因呢

[解决办法]
探讨

谢谢啦,可是这是啥原因呢

[解决办法]
结贴率 !!
[解决办法]
探讨
alert(document.getElementById("<%=asfdoc.ClientID %>").Value);

[解决办法]
探讨

谢谢啦,可是这是啥原因呢

[解决办法]
探讨

alert(document.getElementById("<%=asfdoc.ClientID %>").Value);

读书人网 >asp.net

热点推荐