Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

File Upload weirdness...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Regan - 13 Mar 2008 02:55 GMT
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?
Paul Shapiro - 13 Mar 2008 03:41 GMT
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."

> Ok,
>
[quoted text clipped - 20 lines]
> code behind the button onto a fresh page, with only a FileUpload control
> and a Button, it works perfectly...........
Regan - 13 Mar 2008 06:39 GMT
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 =)

> The online help mentions something about using a file upload control
> within an ajax panel. Maybe this helps?
[quoted text clipped - 31 lines]
>> code behind the button onto a fresh page, with only a FileUpload control
>> and a Button, it works perfectly...........

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.