Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:37:00+00:00 2026-06-13T11:37:00+00:00

What can be wrong with my code? The visual studio doesn’t get any warnings

  • 0

What can be wrong with my code? The visual studio doesn’t get any warnings or error.

ASP.NET, Error Rendering Control – WebUserControl, An unhandled exception has occurred.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"         Inherits="WebUserControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server">

    protected void UploadButton_Click(object sender, EventArgs e)
    {
        // Specify the path on the server to
        // save the uploaded file to.
        String savePath = @"c:\temp\uploads\";

        // Before attempting to perform operations
        // on the file, verify that the FileUpload 
        // control contains a file.
        if (FileUpload1.HasFile)
        {
            // Get the name of the file to upload.
            String fileName = FileUpload1.FileName;

            // Append the name of the file to upload to the path.
            savePath += fileName;


            // Call the SaveAs method to save the 
            // uploaded file to the specified path.
            // This example does not perform all
            // the necessary error checking.               
            // If a file with the same name
            // already exists in the specified path,  
            // the uploaded file overwrites it.
            FileUpload1.SaveAs(savePath);

            // Notify the user of the name of the file
            // was saved under.
            UploadStatusLabel.Text = "Your file was saved as " + fileName;
        }
        else
        {
            // Notify the user that a file was not uploaded.
            UploadStatusLabel.Text = "You did not specify a file to upload.";
        }

    }

</script>

<html  >
<head id="Head1" runat="server">
    <title>FileUpload Example</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            height: 26px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table class="style1">
        <tr>
            <td>
                Select a file to upload:</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style2">

       <asp:FileUpload id="FileUpload1"                 
           runat="server">
       </asp:FileUpload>

            </td>
            <td class="style2">
            </td>
        </tr>
        <tr>
            <td>

       <asp:Button id="UploadButton" 
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>    

            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td>

       <hr />

            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td>

       <asp:Label id="UploadStatusLabel"
           runat="server">
       </asp:Label>        
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    </form>
    <p>
        &nbsp;</p>
</body>
</html>

Error message from web browser:

    Server Error in '/WebSite2' Application.
--------------------------------------------------------------------------------

You can only have one <head runat="server"> control on a page. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: You can only have one <head runat="server"> control on a page.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[HttpException (0x80004005): You can only have one <head runat="server"> control on a page.]
   System.Web.UI.HtmlControls.HtmlHead.OnInit(EventArgs e) +1762795
   System.Web.UI.Control.InitRecursive(Control namingContainer) +333
   System.Web.UI.Control.InitRecursive(Control namingContainer) +210
   System.Web.UI.Control.InitRecursive(Control namingContainer) +210
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
   System.Web.UI.ControlCollection.Add(Control child) +80
   System.Web.UI.WebControls.WebParts.WebPartManagerControlCollection.AddWebPartHelper(WebPart webPart) +220
   System.Web.UI.WebControls.WebParts.WebPartManagerControlCollection.AddWebPartsFromZone(WebPartZoneBase zone, WebPartCollection webParts) +607
   System.Web.UI.WebControls.WebParts.WebPartManager.RegisterZone(WebZone zone) +240
   System.Web.UI.WebControls.WebParts.WebZone.OnInit(EventArgs e) +95
   System.Web.UI.WebControls.WebParts.WebPartZone.OnInit(EventArgs e) +9
   System.Web.UI.Control.InitRecursive(Control namingContainer) +333
   System.Web.UI.Control.InitRecursive(Control namingContainer) +210
   System.Web.UI.Control.InitRecursive(Control namingContainer) +210
   System.Web.UI.Control.InitRecursive(Control namingContainer) +210
   System.Web.UI.Control.InitRecursive(Control namingContainer) +210
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:37:01+00:00Added an answer on June 13, 2026 at 11:37 am

    A usercontrol is embedded in the contents of a page, thus it shouldn’t have a head section. only your actual page should have a header.

    It also should not have any of the other document sections either including html, body, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code (written with Visual Studio 2010 and .NET 4.0) using System;
I'm trying to debug .NET Framework's source code using Visual Studio 2010 Professional. I
I have built my new website in Visual Studio 2010 (C# - ASP.NET 4).
I've got Code Contracts working fine from inside Visual Studio 2010, but I can't
I've found this odd case of some code (below) doesn't compile under Visual Studio
I have a simple Windows App written in Visual Studio 2008 (.NET 3.0, C#).
The visual studio std::vector visualizer in the VS2008 autoexp.dat file doesn't seem to work
I've created a web application project in Visual Studio 2010 using Entity Framework Code
I'm working with C# and the .NET 2.0 framework in Visual Studio 2010. I'm
Whenever I reformat html source code in Visual Studio with Ctrl-K, Ctrl-D it formats

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.