By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

FileUpload in ASP.NET Ajax

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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.