<
iframe id
=
"
file
"
src
=
"
FrameFileBrowse.aspx
"
runat
=
"
server
"
></
iframe
>
在FrameFileBrowse.aspx页面里面不在使用updatepanel控件,结果可以满足自己的要求.后来向同事请教这个问题,一个同事建议使用javascript来实现.并写了一个javascript函数.如下:
<script>
/*读取FileUpload控件所选择文件的文件流*/
1
function Getfileinfo()
2 {
3 var fso , f , file;
4 var ForReading = 1 ;
5 var path = form1 . FileUpload1 . value;
6 fso = new ActiveXObject( " Scripting.FileSystemObject " );
7 file = fso . GetFile(path);
8 f = fso . OpenTextFile(path , ForReading);
9 form1 . TextBox1 . innerText = f . Read (file . Size);
10 f . Close ();
11 }
12 </ script >
2 {
3 var fso , f , file;
4 var ForReading = 1 ;
5 var path = form1 . FileUpload1 . value;
6 fso = new ActiveXObject( " Scripting.FileSystemObject " );
7 file = fso . GetFile(path);
8 f = fso . OpenTextFile(path , ForReading);
9 form1 . TextBox1 . innerText = f . Read (file . Size);
10 f . Close ();
11 }
12 </ script >
添加一个html的button控件,<input id="Button1" type="button" value="读取文件" οnclick="Getfileinfo();" />
结果运行完全可以,在后台可以直接使用TextBox1.Text来读取所要的信息.