Wrox Programmer Forums
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 15th, 2008, 07:28 AM
Registered User
Join Date: Apr 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fileupload in Ajax

Hi to all,
              I want to upload a file i.e image after uploading to hosting server ,the image which uploaded must be visible on the right hand of the file upload control.I did it in normal asp.net page.When i try this whole thing in ajax it shows error.

              After all my research in internet,i concluded that updatepanel control is not supports file uploading process.

              What i have to do now.any valueable suggestion...

Old October 17th, 2008, 10:24 AM
Friend of Wrox
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post

Can you post the exact error you getting, so that we can suggest a resolution accordingly.

Old October 18th, 2008, 03:13 AM
Registered User
Join Date: Apr 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for your reply.

This is on my html side

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate >
           <asp:FileUpload ID="FileUpload1" runat="server" />
              <asp:Button ID="Button1" runat="server" Text="Upload"
            OnClick="Button1_Click" />


On coding side I write just one line

 Protected Sub Btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        FileUpload1.PostedFile.SaveAs(Server.MapPath("./") & "uploadimg.jpg")

    End Sub

Error is :-
Object Reference Not Set to an instance of object.

I know this is very small error .We can over come this error by creating Instance to that object By using 'New' keyword.
At this time i'm feeling difficulty.

Help me.

Old October 18th, 2008, 09:59 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

This problem is due to the design of Ajax and the FileUpload control. It's not something that can be fixed with a New keyword; it's caused by the fact that no file was uploaded, so PostedFile is Nothing...

Search Google or your favorite search engine for "FileUpload ajax problem" for more background and work arounds.



Imar Spaanjaars
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.

Similar Threads
Thread Thread Starter Forum Replies Last Post
FileUpload control aliirfan84 ASP.NET 2.0 Professional 1 June 2nd, 2007 03:37 PM
Recommend an AJAX IDE - JoyiStar AJAX WebShop. kingstar Ajax 4 December 15th, 2006 05:12 AM
FileUpload Control MunishBhatia ASP.NET 2.0 Basics 2 December 6th, 2006 04:03 AM
FileUpload FIlter tony_j_hug ASP.NET 2.0 Basics 1 October 28th, 2005 06:55 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.