开发工具: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
记得结贴
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
结贴率 !!
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------