p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Fileupload in Ajax (http://p2p.wrox.com/showthread.php?t=71039)

bobwith5 October 15th, 2008 07:28 AM

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...

mike_remember October 17th, 2008 10:24 AM

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


bobwith5 October 18th, 2008 03:13 AM

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.

Imar October 18th, 2008 09:59 AM

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.

All times are GMT -4. The time now is 02:55 PM.

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