473,320 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 9705
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TCB | last post by:
I cannot get the value of the selected file in a FileUpload control when using a Callback, is there any way to acomplish this? Thanks
1
by: Harinath | last post by:
Hi All, I am working on a portal using .net2.0. In one of my page, i have FileUpload control. I am doing some server side validation for form fields in general. if there is any validation...
1
by: Nathan Sokalski | last post by:
I have an ASP.NET 2.0 webform which includes both a FileUpload contol and a Calendar control. When the user selects a new data with the Calendar control, the FileUpload control is reset (there is...
6
by: Chris | last post by:
I want do my insert to a database using a formview bound to an objectdatasource. I also want to upload a file. I'm quite new to and this is just test code but Is there any way I can pass the file...
2
by: ronc85 | last post by:
My environment is ASP.NET 2.0, C# and AJAX. Is there a way to retain the Postedfile in the FileUpload control after Postback? I have this application I've inherited were the User chooses a file...
1
by: Code Monkey | last post by:
I've got a FileUpload control placed on a web page. The control is embedded inside an UpdatePanel. It uploads the file OK, but.... Load the page, click on a button to show the upload panel....
3
by: Nathan Sokalski | last post by:
I have a FileUpload control which is inside an UpdatePanel which is inside a TabPanel. In my code, I use the FileUpload's HasFile and FileContent.Length properties. However, after I select a file,...
0
by: thupham | last post by:
I use Visual Studio 2003, and Ajax.dll In design, I have : 1 FileField, named: FileInput, set runnat="server" 1 Button (of Html toolbox), named: cmdUpload 1 Label (of HTML...
6
by: GaryDean | last post by:
Is there any way to make an asp FileUpload control work within an UpdatePanel? Thanks, Garyh
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.