当前位置: 代码迷 >> ASP.NET >> .net里如何选择一个文件地址并附在text框下
  详细解决方案

.net里如何选择一个文件地址并附在text框下

热度:8727   发布时间:2013-02-25 00:00:00.0
.net里怎么选择一个文件地址并附在text框上
如题,在电脑上选择一个文件

------解决方案--------------------------------------------------------
HTML code
    <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()" />
------解决方案--------------------------------------------------------
探讨
HTML code

<div>
<asp:TextBox ID="txtPath" runat="server"></asp:TextBox>
<asp:FileUpload ID="fileUp" runat="server" onchange="showPath()" />
</div>

<script type="te……
  相关解决方案