469,936 Members | 2,422 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

FileUpload in ASP.NET Ajax

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
Jan 11 '08 #1
9 9442
On Jan 11, 3:52 pm, vital <vital.madd...@gmail.comwrote:
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.
Jan 11 '08 #2
"vital" <vi***********@gmail.comwrote in message
news:36**********************************@21g2000h sj.googlegroups.com...
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?

Jan 11 '08 #3
On Jan 11, 4:11*pm, "Leon Mayne" <leon@rmv_me.mvps.orgwrote:
"vital" <vital.madd...@gmail.comwrote in message

news:36**********************************@21g2000h sj.googlegroups.com...
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?
Object reference not set to an instance of an object that is the
error.
Jan 11 '08 #4
On Jan 11, 4:12*pm, Dina <dina.mrc...@gmail.comwrote:
On Jan 11, 3:52 pm, vital <vital.madd...@gmail.comwrote:
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.
I placed it in update panel for partial page rendering.
Jan 11 '08 #5
"vital" <vi***********@gmail.comwrote in message
news:83**********************************@e23g2000 prf.googlegroups.com...
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
}

Jan 11 '08 #6
On Jan 11, 4:28 pm, vital <vital.madd...@gmail.comwrote:
On Jan 11, 4:12 pm, Dina <dina.mrc...@gmail.comwrote:
On Jan 11, 3:52 pm, vital <vital.madd...@gmail.comwrote:
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.

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?
Jan 11 '08 #7
"Leon Mayne" <leon@rmv_me.mvps.orgwrote in message
news:4F**********************************@microsof t.com...
"vital" <vi***********@gmail.comwrote in message
news:83**********************************@e23g2000 prf.googlegroups.com...
>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
}

Also, remember to find the upload control first:

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

Jan 11 '08 #8
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)
"vital" wrote:
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
Jan 11 '08 #9
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.

"vital" <vi***********@gmail.comwrote in message
news:36**********************************@21g2000h sj.googlegroups.com...
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

Jan 11 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by TCB | last post: by
1 post views Thread by Harinath | last post: by
6 posts views Thread by Chris | last post: by
2 posts views Thread by ronc85 | last post: by
1 post views Thread by Code Monkey | last post: by
6 posts views Thread by GaryDean | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.