File Upload using AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kmithu
    New Member
    • Jun 2007
    • 11

    File Upload using AJAX

    Hi friends,

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

    ----------------------------------------------------------------------------------------
    [HTML]<asp:ScriptMana ger ID="ScriptManag er1" runat="server" />
    <asp:UpdatePane l ID="UpdatePanel 1" runat="server">
    <ContentTemplat e>
    <asp:FileUplo ad ID="FileUpload1 " runat="server" />
    <asp:Button ID="Button1" runat="server" OnClick="Button 1_Click" Text="Button" />
    </ContentTemplate >
    </asp:UpdatePanel >
    [/HTML]-----------------------------------------------------------------------------------------
    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.File Name;

    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.
    Last edited by acoder; Sep 12 '07, 10:37 AM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    See this thread and this one. An Ajax file upload is not really possible in the normal way. Use an iframe to make it seem as if it's uploaded on the same page without refreshing.

    Comment

    Working...