C sharp - file upload issue

I have a form and it is supposed to upload files to the server.
Attached is the code:

This is the error I get  "{"Object reference not set to an instance of an object."}"
    <form id="form1" runat="server">
                <td colspan="3" style="height: 21px">
                    Upload Files</td>
                <td style="width: 100px">
                    Choose a file to upload</td>
                <td style="width: 100px">
                    <input id="File1" type="file" /></td>
                <td style="width: 100px">
                    <input id="Button1" type="button" value="Upload" runat="server" onserverclick="Button1_ServerClick" /></td>
C# Code Behind
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page 
    protected System.Web.UI.HtmlControls.HtmlInputFile File1;
    protected System.Web.UI.HtmlControls.HtmlInputButton Submit1;
    protected void Page_Load(object sender, EventArgs e)
    protected void Button1_ServerClick(object sender, EventArgs e)
        if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))     <--- Error points here
            string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
            string SaveLocation = Server.MapPath("Upload") + "\\" + fn;
                Response.Write("The file has been uploaded.");
            catch (Exception ex)
                Response.Write("Error: " + ex.Message);
                //Note: Exception.Message returns a detailed message that describes the current exception. 
                //For security reasons, we do not recommend that you return Exception.Message to end users in 
                //production environments. It would be better to put a generic error message. 
            Response.Write("Please select a file to upload.");

Open in new window

IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


<INPUT type=file id=File1 name=File1 runat="server" />

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IsaacSharePoint Client Side DeveloperAuthor Commented:
Now I get this error:

Compiler Error Message: CS0102: The type '_Default' already contains a definition for 'File1'
Line 13:     protected System.Web.UI.HtmlControls.HtmlInputFile File1;
delete line 13
Line 13:     protected System.Web.UI.HtmlControls.HtmlInputFile File1;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.