C# .NET - How to maintain File upload Control file name When Post Back Occur

Asked By Lipa Bera on 29-May-15 12:10 AM
In my form I have a File Upload Control. After selecting a file from local machine, there is a button to validate if the file selected is of required format or not. On click it gives a pop up. After the pop the file name from the File Upload control vanishes. I want to retain this filename so that no need to browse for once again to do the next task.
Robbe Morris replied to Lipa Bera on 29-May-15 08:55 AM
The File Upload control does not permit you to do that for security reasons.
arockiaraj a replied to Lipa Bera on 03-Jun-15 11:29 PM
USE UPDATE PANEL


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
        <table style="width: 100%;">
            <tr>
                <td>
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:Label ID="Label1" runat="server" Text="Select File"></asp:Label>
                </td>
                <td>
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                </td>
                <td>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>