I am trying to add a fileupload control to my aspx page so the user can add pictures, but when I am implementing the code behind on VB the fileuploader controler is not recognized.
I have this on aspx page inside a formview:
<InsertItemTemplate>
<div id="TaskScreenError">
Upload a Screenshot of Error:
<asp:FileUpload ID="ErrorScreen" runat="server" />
</div>
<InsertItemTemplate>
And I have the following code on my VB, but it says ErrorScreen is not declared.
Dim filereceived As String = ErrorScreen.PostedFile.FileName
' validate the file to ensure it is an image
Select Case Right(filereceived, 4)
Case ".jpg", ".tif", ".bmp", ".gif"
Case Else
lblErrMsg.Text = "Image is in a format we don't accept, please use jpg, tif, bmp or gif."
Exit Sub
End Select
...
It might be something really stupid but I cant figure it out what is the problem.
Please help.
Cheers
Since your FileUpload control is inside the InsertTemplate, you cannot access the FileUpload control directly. You have to do something like this: