当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - define an array of input control in aspx.cs

问题描述:

i have an input control of type file.

<input id="FileUpload1" type="file" runat="server" size="35" />

there are four input controls like this and in aspx.cs file i m trying to make an array of these ids..

i have made an array

HtmlInputFile[] fl = new HtmlInputFile[4] { FileUpload1, FileUpload2, FileUpload3, FileUpload4 };

but it gives me an error..how can i get the value of these inputs.

网友答案:

The

FileUploadX.PostedFile 

Property is null if no file was uploaded. You need to check wether

FileUploadX.HasFile == true 

before attempting to access it.

In case you are using ASP.Net AJAX updatepanels, you'll run into all sorts of proplems with FileUpload. See http://geekswithblogs.net/mmintoff/archive/2009/04/01/fileupload-within-updatepanel.aspx for possible solutions

分享给朋友:
您可能感兴趣的文章:
随机阅读: