日期:2014-05-17 浏览次数:20394 次
<div> <asp:TextBox ID="txtPath" runat="server"></asp:TextBox> <asp:FileUpload ID="fileUp" runat="server" onchange="showPath()" /> </div> <script type="text/javascript"> function showPath() { var file = document.getElementById('<%=fileUp.ClientID %>'); document.getElementById('txtPath').value = file.value; } </script>
------解决方案--------------------
<script type="text/javascript">
function getFilePath()
{
document.getElementById("fileFast").select(); //选中FileUpload控件中的文本
var path = document.selection.createRange().text; //获取当前文本选中的文本document.selection.empty();
document.getElementById('<%=TextBox1.ClientID%>').value=path;
}
</script>
<input type="file" id="fileFast" runat="server"/>
<input type="button" id="ibtnFast" value ="复制地址" onclick="getFilePath()" />
------解决方案--------------------