HERE IS THE CODE:
PAGE.ASPX
<asp:FileUpload ID="fupBlogImg1" runat="server" Width="298px" />
<asp:FileUpload ID="fupBlogImg2" runat="server" Width="298px" />
............
<asp:FileUpload ID="fupBlogImg9" runat="server" Width="298px" />
<asp:Button ID="cmdAlbumCreate" runat="server" Text="Inserir imagens no álbum" OnClick="cmdAlbumCreate_Click" />
PAGE.ASPX.CS
protected void cmdAlbumCreate_Click(object sender, EventArgs e)
{
FileUpload fupBlogImg1 = (FileUpload)FindControl("fupBlogImg1");
FileUpload fupBlogImg2 = (FileUpload)FindControl("fupBlogImg2");
.............
FileUpload fupBlogImg9 = (FileUpload)FindControl("fupBlogImg9");
but fupBlogImg1,2...9 is returning null. I have tryied Page.FindControl but didnt work
If you need anything else to get a better understanding pls let me know.
TY
You don't need to Redeclare the FileUplaod controls.
You have declared them in your aspx code and these variables can be accessed in your C# code.
For instance if you want to retrieve the file name of the file being uploaded in the fupBlogImg9 you would do something like:
String fileName = fupBlogImg9.FileName;
You don't need to do this:
FileUpload fupBlogImg9 = (FileUpload)FindControl("fupBlogImg9");
You already have a fupBlogImg9 FileUpload control to use.
I think you're losing the object state for your FileUpload control when you are redeclaring it.