Alex Rivera | Logout

Type '_Default' already defines a member called 'Page_Load' with the same parameter types

Asked 2011-04-01T08:41:09.153
10

I've been renaming some classes and packages in my aspx project and now i have this error:

"Type '_Default' already defines a member called 'Page_Load' with the same parameter types"

I have two aspx pages. In the default.aspx codebehind i see:

Default.aspx:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="_Default" %>

Default.aspx.cs:

public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        //error line under 'Page_Load'
    }

search.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="search.aspx.cs" Inherits="_Default" %>

search.aspx.cs:

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

    }

Every new ASPX page I add to my project is automaticly added to some namespace.

I've tried changing the inherits attribuut. But i couldn't find a way to fix this error and to get rid of the namespace.

I'm using Visual Studio 2010.

My project structure

Edit
Report

1 Answer

5

Just to add up a specific case.

You can come across to this situation when you convert Web Site into Web Application.

When your project in form of Web Site, when you add for example Default.aspx into two different folders they both created without namespace with the same class name. Both declared partial and it is just fine. But when you convert into Web Application and try to build they start conflicting as they are in the same namespace, declared partial and have their own Page_Load methods.

One of the solutions can be giving distinct class names or encapsulating into different namespaces in accordance with the folder structure.

answered 2012-09-27T20:22:45.273

Your Answer