FILEUPLOAD.HASFILE() ALWAYS NULL

Pravesh Singh

Total Post:101

Points:709
Posted by  Pravesh Singh
 1380  View(s)
Ratings:
Rate this:

This is the code I use for my UpdatePanel.

The FileUploadAsync.HasFile() is always null.

I am wondering what is wrong with my asp.net page ...

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" />

<asp:UpdatePanel ID="UpdatePanelAddFiles" runat="server" UpdateMode="Conditional">

    <Triggers>

        <asp:AsyncPostBackTrigger ControlID="LkUpload" />

    </Triggers>

    <ContentTemplate>

    <asp:LinkButton ID="LkUpload" runat="server" OnClick="LkUpload_Click" Visible="false">Upload</asp:LinkButton>

        <ajaxToolkit:AsyncFileUpload runat="server" ID="FileUploadAsync" />

    </ContentTemplate>

</asp:UpdatePanel>

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: FileUpload.HasFile() always null

    Hi Pravesh, 


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="futest.aspx.cs" Inherits="erpweb.futest" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

        <title></title>

    </head>

    <body>

        <form id="form1" runat="server">

        <div>

        <asp:ScriptManager ID="smTest" runat="server"></asp:ScriptManager>

        <asp:UpdatePanel ID="upTest" runat="server">

            <ContentTemplate>

                <ajaxToolkit:AsyncFileUpload ID="AsyncFileUpload1" runat="server"

                    onuploadedcomplete="AsyncFileUpload1_UploadedComplete" />

            </ContentTemplate>

        </asp:UpdatePanel>

        </div>

        </form>

    </body>

    </html>

    codebehind:

        protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)

        {

            if (AsyncFileUpload1.HasFile)

            {

                //do save process here

            }

        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!