Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem using asp control inside an asp.net web application project

Status
Not open for further replies.

damonh78

Programmer
Jul 28, 2005
44
IE
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" />&nbsp;<br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label></div>
</form>
</body>
</html>
 
Can you provide the full code of the page that doesn't work (I'm assuming what you provided above is the page that does work)?

Also, when pasting the code, please embed it in [ignore]
Code:
[/ignore] tags.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi,

apologies will use the tags from now on when including code.
Thats the thing I am using the same code in both. All I do is create a blank Visual c# project using the asp.net web application template and then in the blank WebForm1.aspx page thats created I click on the html tab and overwrite whats there with the above code.

John
 
What happens if you just create a new FileUpload control on the new page? Does that work?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
no that doesnt work, I notice that when I start to type <asp:FileUpLoad> the drop down menu that appears to let me autofill in what I am writing, does not contain <asp:FileUpLoad>. Could there be a problem with the way something is configured to its using the wrong version of ASP.Net? I know that the fileupload control is not present in 1.1. But from the commandline I ran the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i. This sets up 2.0 as the version I am using, do I need to something in visual studion as well (just an idea)?
 
What version of Visual Studio are you using?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
think I have found the problem, I am using that Visual Studio 2003, which I just found out uses .net 1.1. The fileupload control is not present in 1.1. I have converted the project to a Visual Studio 2005 project and it works fine so alls good now. Thanks alot for your help.

John
 
In VS2003, there is an HTML file upload control, in VS2005, a server control has been added.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top