473,387 Members | 1,510 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,387 software developers and data experts.

Uploading File using AJAX

11
Hi friends,

I want to upload a file on AJAX web page. The HTML code i m using is:

----------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <asp:ScriptManager ID="ScriptManager1" runat="server" />
  2. <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  3. <ContentTemplate>
  4. <asp:FileUpload ID="FileUpload1" runat="server" />
  5. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
  6. </ContentTemplate>
  7. </asp:UpdatePanel>
  8.  
-----------------------------------------------------------------------------------------
The problem is that when i run the program the page gets Auto postback and the value in the fileUpload gets cleared. and the error of "object reference cannot be set to null" comes on the below line.....

string st=FileUpload1.PostedFile.FileName;

I tried using viewstate but still the problem is of Autopostback......
No effect with triggers and update mode set to conditional....Please help me out.
Aug 3 '07 #1
3 1408
kenobewan
4,871 Expert 4TB
Often placing a check for not.ispostback helps.
Aug 3 '07 #2
Frinavale
9,735 Expert Mod 8TB
The FileUpload control is one of the few controls that does not work within an UpdatePanel. It requires a full page PostBack to work.

Take your FileUpload control out of the UpdatePanel and it will work.

Cheers!

-Frinny
Aug 3 '07 #3
This post describes all the controls that dont' currently work in in the updatepanel control (unless you do a full postback via a trigger).

http://www.asp.net/ajax/documentatio...lOverview.aspx
Aug 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
2
by: Igor | last post by:
Hi I'm writing script using AJAX and PHP to upload files. I'm trying to create progress bar to show how many bytes have been already uploaded to server. Can I get the total file size (using...
3
by: jayainfitech | last post by:
Hi I would like to have the sample code for file upload via AJAX. I searched on the net and came to know that it is not possible directly. But we can do it through hidden IFrame. Thanks in advance
1
by: santhubaba | last post by:
Hi All, I am facing a problem with ajax in dotnet(c#) page My problem is as follows: There is a grid with many buttons , one of the buttons is "Upload" ,if i click on that upload then...
1
by: Ram | last post by:
hi, i'm trying to upload files. i used <input type=file id=Uploadfile runat=server">. i have placed the control in Updatepanel(AJAX) when i'm trying to upload it.. it is showing Object...
3
by: Ajinkya | last post by:
Hello , Can any body tell me how to add progress bar while uploading image with the help of JavaScript or AJAX . I built application by using PHP & HTML. If you have any code or link from that I...
5
by: sarika | last post by:
Hi all I want to upload an image in my website using ajax and php i.e without refreshing the page i want to upload image . Plz help its very urgent
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.