Ok,

So, I'm a .NET/AJAX web application (VB.NET) and in one of my content
screens, among a barrage of controls and panels, I have a File Upload
control... nothing fancy.
Below the control there is a standard button called aFile_btn.

This is the click event of aFile_btn:
---------------------------------------------------------------
Protected Sub aFile_btn_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
If FileUpload1.PostedFile.FileName <> "" Then
End If
End Sub
--------------------------------------------------------------

Simple? I thought so. But when I run the app and click aFile_btn I get the
following error on the "If" line:

Object reference not set to an instance of an object.

You think that's frustrating? there's more. If I copy and paste the exact
code behind the button onto a fresh page, with only a FileUpload control and
a Button, it works perfectly...........

Any ideas?

Re: File Upload weirdness... by Paul

Paul
Wed Mar 12 21:41:58 CDT 2008

The online help mentions something about using a file upload control within
an ajax panel. Maybe this helps?
"The FileUpload control is designed to be used only in postback scenarios
and not in asynchronous postback scenarios during partial-page rendering.
When you use a FileUpload control inside an UpdatePanel control, the file
must be uploaded by using a control that is a PostBackTrigger object for the
panel. UpdatePanel controls are used to update selected regions of a page
instead of updating the whole page with a postback. For more information,
see UpdatePanel Control Overview and Partial-Page Rendering Overview."

"Regan" <regan.thomas@hotmail.com> wrote in message
news:eSJ3D1KhIHA.2540@TK2MSFTNGP05.phx.gbl...
> Ok,
>
> So, I'm a .NET/AJAX web application (VB.NET) and in one of my content
> screens, among a barrage of controls and panels, I have a File Upload
> control... nothing fancy.
> Below the control there is a standard button called aFile_btn.
>
> This is the click event of aFile_btn:
> ---------------------------------------------------------------
> Protected Sub aFile_btn_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> If FileUpload1.PostedFile.FileName <> "" Then
> End If
> End Sub
> --------------------------------------------------------------
>
> Simple? I thought so. But when I run the app and click aFile_btn I get the
> following error on the "If" line:
>
> Object reference not set to an instance of an object.
>
> You think that's frustrating? there's more. If I copy and paste the exact
> code behind the button onto a fresh page, with only a FileUpload control
> and a Button, it works perfectly...........


Re: File Upload weirdness... by Regan

Regan
Thu Mar 13 00:39:26 CDT 2008

Hi Paul,

I took your advice and it worked. It wasn't only the update panels; it was
the ScriptManager as well that was causing the problem.
I separated the file upload page and removed the ajax items from it and
all's sane again.

Thanks for your quick response =)


"Paul Shapiro" <paul@hideme.broadwayData.com> wrote in message
news:e3jjPPLhIHA.5204@TK2MSFTNGP02.phx.gbl...
> The online help mentions something about using a file upload control
> within an ajax panel. Maybe this helps?
> "The FileUpload control is designed to be used only in postback scenarios
> and not in asynchronous postback scenarios during partial-page rendering.
> When you use a FileUpload control inside an UpdatePanel control, the file
> must be uploaded by using a control that is a PostBackTrigger object for
> the panel. UpdatePanel controls are used to update selected regions of a
> page instead of updating the whole page with a postback. For more
> information, see UpdatePanel Control Overview and Partial-Page Rendering
> Overview."
>
> "Regan" <regan.thomas@hotmail.com> wrote in message
> news:eSJ3D1KhIHA.2540@TK2MSFTNGP05.phx.gbl...
>> Ok,
>>
>> So, I'm a .NET/AJAX web application (VB.NET) and in one of my content
>> screens, among a barrage of controls and panels, I have a File Upload
>> control... nothing fancy.
>> Below the control there is a standard button called aFile_btn.
>>
>> This is the click event of aFile_btn:
>> ---------------------------------------------------------------
>> Protected Sub aFile_btn_Click(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>> If FileUpload1.PostedFile.FileName <> "" Then
>> End If
>> End Sub
>> --------------------------------------------------------------
>>
>> Simple? I thought so. But when I run the app and click aFile_btn I get
>> the following error on the "If" line:
>>
>> Object reference not set to an instance of an object.
>>
>> You think that's frustrating? there's more. If I copy and paste the exact
>> code behind the button onto a fresh page, with only a FileUpload control
>> and a Button, it works perfectly...........
>