Using FileUpload in asp.net Web form panel attribute?

340 Views Asked by At

My fileuploader.HasFile always false when I am trying to upload a file inside asp:Panel attribute.

<asp:Panel ID="pnlDetay" runat="server" Visible="false">
            <table>
                
                <tr>
                    <td style="width: 175px; text-align: right; vertical-align: central">
                        <asp:Label ID="Label12" runat="server">Belge</asp:Label>
                    </td>
                    <td style="width: 200px; text-align: left">
                        <asp:DropDownList ID="ddl_BELGELER_BelgeTanimID" runat="server" Width="200px"></asp:DropDownList>
                    </td>

                    <td style="width: 175px; text-align: right">
                        <asp:Label ID="lbl_BelgeYol" runat="server"></asp:Label>
                    </td>
                    <td id="td_BelgeIndir" runat="server" style="width: 175px; text-align: left">
                        <asp:TextBox ID="txt_BELGELER_BelgeYol" runat="server" Style='text-align: left' Width="175" Enabled="false"></asp:TextBox>
                        <a runat="server" id="lnk_Indir" style="float: none;"
                            target="_blank" href="../../Images/filedownload.png">
                            <img style="border-style: none; border-width: 0;" src="../../Images/filedownload.png" /><b>Belgeyi İndir</b></a>
                    </td>
                    <td id="td_BelgeYukle" runat="server" style="width: 175px; text-align: right">
                        <asp:FileUpload id="FileUploadControl" runat="server" Width="125px" /> // THIS IS MY FILEUPLOAD
                        <asp:Button runat="server" id="UploadButton" height="25px" text="Yükle" onclick="UploadButton_Click" />
                    </td>
                </tr>
            </table>
        </asp:Panel>

this code is inside a Panel

and this is code behind:

protected void UploadButton_Click(object sender, EventArgs e)
{
    if (FileUploadControl.HasFile) // Always false
    {
        try
        {
            string filename = Path.GetFileName(FileUploadControl.FileName);
            FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
            //StatusLabel.Text = "Upload status: File uploaded!";
        }
        catch (Exception ex)
        {
            //StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
        }
    }
}

I saw examples about UpdatePanel but not for Panel. I can't use Triggers here.

EDIT: I added full markup of my asp:Panel code. Also my Page_Load method is not doing anything at this page right now.

0

There are 0 best solutions below