FileUpload in ASP.NET Ajax

V

vital

Hi,

I have a User control which has a fileupload control. With the
requirements I placed the user control in a UpdatePanel of ASP.NET
Ajax and the fileupload.postedfile.filename giving error.

I read some articles that Ajax is not compatible with fileupload. I
want to know the solution or workaround for this.

Thanks
 
L

Leon Mayne

vital said:
I have a User control which has a fileupload control. With the
requirements I placed the user control in a UpdatePanel of ASP.NET
Ajax and the fileupload.postedfile.filename giving error.

I read some articles that Ajax is not compatible with fileupload. I
want to know the solution or workaround for this.

What is the exception message you are getting?
 
D

Dina

Hi,

I have a User control which has a fileupload control. With the
requirements I placed the user control in a UpdatePanel of ASP.NET
Ajax and the fileupload.postedfile.filename giving error.

I read some articles that Ajax is not compatible with fileupload. I
want to know the solution or workaround for this.

Thanks

Elaborating on why you placed the user control in UpdatePanel might
help other give you a good solution.
 
V

vital

Elaborating on why you placed the user control in UpdatePanel might
help other give you a good solution.

I placed it in update panel for partial page rendering.
 
L

Leon Mayne

vital said:
Object reference not set to an instance of an object that is the
error.

Are you trying to call postedfile.filename when they have not posted a file?
Try checking first:

VB:
If FileUpload1.PostedFile IsNot Nothing then
' Do something with FileUpload1postedfile.filename
End If

C#:
If (FileUpload1.PostedFile != null){
// Do something with FileUpload1postedfile.filename
}
 
D

Dina

I placed it in update panel for partial page rendering.

Obviously you are placing it in a UpdatePanel for partial page
rendering. What is required is what is the content that you want to
refresh through Ajax and how is the content linked to your file upload
control. Or is it the file upload that you want to achieve through
Ajax?
 
L

Leon Mayne

Leon Mayne said:
Are you trying to call postedfile.filename when they have not posted a
file? Try checking first:

VB:
If FileUpload1.PostedFile IsNot Nothing then
' Do something with FileUpload1postedfile.filename
End If

C#:
If (FileUpload1.PostedFile != null){
// Do something with FileUpload1postedfile.filename
}


Also, remember to find the upload control first:

Dim fup As FileUpload =
CType(Me.UpdatePanel1.ContentTemplateContainer.FindControl("fupTest"),
FileUpload)
If fup.HasFile Then
Response.Write(fup.FileName)
End If
 
B

bruce barker

the fileupload control can not be used in an update panel unless you force a
normal postback, instead of a partial. there is no way (short of an active/x
control) for javascript to read the file and send the data via async method.

if you want to upload a file without rerending the page, you will need to
use an iframe, that you do a full post to.


-- bruce (sqlwork.com)
 
G

George Ter-Saakov

You can not use fileupload control with AJAX
Update panel is pure JavaScript and it's not possible (due to security) for
JavaScript to grab file from your local hard drive and submit it to the
server.

So you will have to make normal post back to upload a file. Just move it out
of the UpdatePanel or make an
"upload" popup with Dialog extender and IFRAME.

George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top