Home > DeveloperSection > Forums > FileUpload.HasFile() always null
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    September-03-2014 11:21 PM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 1014  View(s)
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>



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-03-2014 11:43 PM

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

        }

    }


Don't want to miss updates? Please click the below button!

Follow MindStick