Hi,
I am a complete asp.net newbie so apologies if I get terminology or otherwise incorrect.
I am trying to use the asp:FileUpLoad control to create a webpage that simply uploads a file to my server.
This works fine when I simply create a standlone aspx file and place it in my IIS webroot directory.
My problem is when I try to add this aspx file to a new Web application project. Whenever I do this Visual Studio says that "the active schema does not support the element 'asp:fileupload'". I am simply creating a blank project and copying the html code in from the standalone aspx to the blank WebForm1.aspx file created in the new project.
What exactly am I doing wrong, why wont it work in the project?
Any help would be greatly appreciated.
Thanks,
John
The code for the upload page is:
<%@ Page language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
try
{
FileUpload1.SaveAs("C:\\Sandbox\\" +
FileUpload1.FileName);
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "<br>" +
FileUpload1.PostedFile.ContentLength + " kb<br>" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
else
{
Label1.Text = "You have not specified a file.";
}
}
</script>
<html >
<head runat="server">
<title>Upload Files</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Upload File" /> <br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label></div>
</form>
</body>
</html>
I am a complete asp.net newbie so apologies if I get terminology or otherwise incorrect.
I am trying to use the asp:FileUpLoad control to create a webpage that simply uploads a file to my server.
This works fine when I simply create a standlone aspx file and place it in my IIS webroot directory.
My problem is when I try to add this aspx file to a new Web application project. Whenever I do this Visual Studio says that "the active schema does not support the element 'asp:fileupload'". I am simply creating a blank project and copying the html code in from the standalone aspx to the blank WebForm1.aspx file created in the new project.
What exactly am I doing wrong, why wont it work in the project?
Any help would be greatly appreciated.
Thanks,
John
The code for the upload page is:
<%@ Page language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
try
{
FileUpload1.SaveAs("C:\\Sandbox\\" +
FileUpload1.FileName);
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "<br>" +
FileUpload1.PostedFile.ContentLength + " kb<br>" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
else
{
Label1.Text = "You have not specified a file.";
}
}
</script>
<html >
<head runat="server">
<title>Upload Files</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Upload File" /> <br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label></div>
</form>
</body>
</html>