用一个button控件调用fileupload控件的获取路径功能

让一个FileUpload控件隐藏,当点击一个按钮时让FileUpload控件相应,弹出文件选择对话框,选择文件后得到文件路径

想要得到完整的路径 需要设置IE浏览器的“工具——Internet选项——安全——可信站点——站点——添加一个(http://localhost)——把下面那个勾选 取消”

 

<head   runat="server"> 
        <title> 无标题页 </title> 
        <script   type="text/javascript"   language="javascript"> 
        function   test(){ 
                document.getElementById("FileUpload1").style.display="inline"; 
                document.getElementById("FileUpload1").click(); 
        } 
        </script> 
</head> 
<body> 
        <form   id="form1"   runat="server"> 
        

        <asp:FileUpload   ID="FileUpload1"   runat="server"   /> 
        <input   id="Button1"   type="button"   value="button"   onclick="test();"/> 
</form>

 

后台.CS

protected   void   Page_Load(object   sender,   EventArgs   e) 
        { 
                this.FileUpload1.Style.Add("display",   "none"); 
        }

 

posted @ 2013-08-01 14:03  JasonGu0  阅读(591)  评论(0)    收藏  举报