开发者

Asp.net custom ajax file uploader

I develop custom file uploader.

<asp:FileUpload runat="server" ID="fuUpload" />

<asp:UpdatePanel  runat="server" >
    <ContentTemplate>
     <asp:Button ID="btnUpload" runat="server" Text="Upload" CausesValidation="false"
            OnClick="btnUpload_Click" />

      <div>
        <asp:Label ID="lblError" runat="server" Visible="false" ForeColor="Red" /></div>
        <asp:Repeater ID="rptAttachments" runat="server" OnItemCommand="Uploader_ItemCommand">
            <ItemTemplate>
                <div>
                    <a href='<%#GetUrl(....) %>'><%#Eval("Filename") %></a> <b>
                   <asp:LinkButton ID="lnkDelete" runat="server" Text="Удалить" CommandName="DeleteAttachment" CommandArgument='<%#Eval("FileName") %>' /></b>
                </div>
            </ItemTemplate>
        </asp:Repeater>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnUpload" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="rptAttachments" EventName="ItemCommand" />
    </Triggers>
</asp:UpdatePanel>




 protected void btnUpload_Click(object sender, EventArgs e)
  {          
   //fuUpload.HasFile == false 
    if (fuUpload.HasFile && fuUpload.PostedFile != null 
        && fuUpload.PostedFile.ContentLength > 0)
     { 
     }
  }

I wonder why fuUpload.HasFil开发者_如何学Goe always equls null.


Try these things.

  1. Put <asp:FileUpload runat="server" ID="fuUpload" /> inside UpdatePanel
  2. Set btnUpload trigger like this. <asp:PostBackTrigger ControlID="btnUpload" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜