简体   繁体   English

在aspx.cs中定义输入控件的数组

[英]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.. 有四个这样的输入控件,并且在aspx.cs文件中,im试图创建这些id的数组。

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. 如果未上传文件,则属性为null。 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. 如果您使用的是ASP.Net AJAX更新面板,则FileUpload会遇到各种各样的问题。 See http://geekswithblogs.net/mmintoff/archive/2009/04/01/fileupload-within-updatepanel.aspx for possible solutions 有关可能的解决方案,请参见http://geekswithblogs.net/mmintoff/archive/2009/04/01/fileupload-within-updatepanel.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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