FileUpload in ASP.NET Ajax
FileUpload in ASP.NET Ajax
am 11.01.2008 11:52:25 von 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
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:11:09 von Leon Mayne
"vital" wrote in message
news:3631f1ba-4cd2-454b-a652-4bf27c064d93@21g2000hsj.googleg roups.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?
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:12:29 von Dina
On Jan 11, 3:52 pm, 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
Elaborating on why you placed the user control in UpdatePanel might
help other give you a good solution.
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:27:05 von vital
On Jan 11, 4:11=A0pm, "Leon Mayne" wrote:
> "vital" wrote in message
>
> news:3631f1ba-4cd2-454b-a652-4bf27c064d93@21g2000hsj.googleg roups.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.
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:28:03 von vital
On Jan 11, 4:12=A0pm, Dina wrote:
> On Jan 11, 3:52 pm, 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
>
> 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.
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:39:09 von Leon Mayne
"vital" wrote in message
news:83286822-ac0d-46e8-ade3-ac3c985f2bfa@e23g2000prf.google groups.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
}
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:45:42 von Dina
On Jan 11, 4:28 pm, vital wrote:
> On Jan 11, 4:12 pm, Dina wrote:
>
> > On Jan 11, 3:52 pm, 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
>
> > 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?
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 12:50:23 von Leon Mayne
"Leon Mayne" wrote in message
news:4F283746-91D8-4BEC-94C2-F28A3E60AD27@microsoft.com...
> "vital" wrote in message
> news:83286822-ac0d-46e8-ade3-ac3c985f2bfa@e23g2000prf.google groups.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.FindControl(" fupTest"),
FileUpload)
If fup.HasFile Then
Response.Write(fup.FileName)
End If
RE: FileUpload in ASP.NET Ajax
am 11.01.2008 17:35:11 von brucebarker
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
>
Re: FileUpload in ASP.NET Ajax
am 11.01.2008 17:42:24 von 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.
"vital" wrote in message
news:3631f1ba-4cd2-454b-a652-4bf27c064d93@21g2000hsj.googleg roups.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