473,783 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.post edfile.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 9742
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.post edfile.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******** *************** ***********@21g 2000hsj.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.post edfile.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.mv ps.orgwrote:
"vital" <vital.madd...@ gmail.comwrote in message

news:36******** *************** ***********@21g 2000hsj.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.post edfile.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...@gm ail.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.post edfile.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******** *************** ***********@e23 g2000prf.google groups.com...
Object reference not set to an instance of an object that is the
error.
Are you trying to call postedfile.file name when they have not posted a file?
Try checking first:

VB:
If FileUpload1.Pos tedFile IsNot Nothing then
' Do something with FileUpload1post edfile.filename
End If

C#:
If (FileUpload1.Po stedFile != null){
// Do something with FileUpload1post edfile.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...@gm ail.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.post edfile.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.mv ps.orgwrote in message
news:4F******** *************** ***********@mic rosoft.com...
"vital" <vi***********@ gmail.comwrote in message
news:83******** *************** ***********@e23 g2000prf.google groups.com...
>Object reference not set to an instance of an object that is the
error.

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

VB:
If FileUpload1.Pos tedFile IsNot Nothing then
' Do something with FileUpload1post edfile.filename
End If

C#:
If (FileUpload1.Po stedFile != null){
// Do something with FileUpload1post edfile.filename
}

Also, remember to find the upload control first:

Dim fup As FileUpload =
CType(Me.Update Panel1.ContentT emplateContaine r.FindControl(" 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.post edfile.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******** *************** ***********@21g 2000hsj.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.post edfile.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
2166
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
3268
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 missing control comes back to the user. All other fields in the screens are retaining their values, but the
1
1975
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 no longer a file selected if one was previously selected). I am assuming this is because the Calendar control causes a postback when a date is selected. Does anyone know of a way to prevent this from happening? Thanks. -- Nathan Sokalski...
6
7345
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 as a byte array and manipulate it in my business object. Currently what I have is this, but my byte array in my business object is nothing. It's like it's not passed the file as a stream. I think I am not binding the FileUpload to the...
2
11395
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 then clicks the "save" button, the program proceeds to edit the file on the server and if it detects an error displays an error message. At this point the filename is lost from the FileUpload input field. Sal P.
1
1481
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. Select a file, click the upload button. File NOT uploaded. Select the file again, and click the upload button, THEN and ONLY then
3
8668
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, the HasFile=False, and the FileContent.Length=0. Why is this? Does it have something to do with the TabPanel and UpdatePanel being AJAX? If so, what can I do to fix it? Is there something else I could be doing wrong? Any help would be appreciated....
0
1199
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 toolbox), named: lblInfo First I create function for customer upload their file to server on click event: private void cmdUpload_Click(object sender, System.EventArgs e) { if (FileInput.PostedFile.FileName == "")
6
2087
by: GaryDean | last post by:
Is there any way to make an asp FileUpload control work within an UpdatePanel? Thanks, Garyh
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.