简体   繁体   中英

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 im 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM