Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
.cs code
-----------
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace samples
{
    public partial class UploadAndDownloadFiles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnupload_Click(object sender, EventArgs e)
        {
            if (uploadfile.HasFile)
            {

            string filename = uploadfile.PostedFile.FileName;
            }
        }
    }
}




.aspx
----------
XML
<body>
    <form id="form1" runat="server">
     <asp:ScriptManager ID="scrmang" runat="server" EnableCdn="true">
    </asp:ScriptManager>
    <br />
    <asp:UpdatePanel ID="uploadpnl" runat="server">
    <ContentTemplate>
    <div class="colr">
    <center>
    <div>
    <br />
    <table>
    <tr>
    <td>Upload File :</td>
    <td> <asp:FileUpload ID="uploadfile" runat="server" /></td>
    </tr>
    <tr>
    <td>Document Name :</td>
    <td>
    <asp:TextBox ID="txtdocumentname" class="size" runat="server" ></asp:TextBox>
    </td>
    </tr>
     <tr>
    <td>
    <asp:Button ID="btnupload" CssClass="btn btn-warning" runat="server" Text="Upload File" OnClick="btnupload_Click" />
    </td>
    </tr>
    </table>


    </div>
    </center>
    </div>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnupload" EventName="Click" />
    </Triggers>
    </asp:UpdatePanel>
    </form>
</body>
Posted
Updated 8-May-14 0:43am
v2
Comments
CHill60 8-May-14 6:36am    
Your problem is not clear. Use the "Improve question" link to change the title to something (a lot) shorter and put your question into the body of your post. Try to explain in different words what you problem is.

1 solution

Shouldn't you be using:
C#
if(FileUploadControl.HasFile){}


Have a look at this link:
http://asp.net-tutorials.com/controls/file-upload-control/[^]

regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900