0

I wanted to copy my .aspx file and paste it with all its content, but I run into an error.

this is what I did : 1. Copy - Paste. 2. rename the new aspx file in the solution explorer. 3. rename the Inherits in the aspx file (the "code behind" there was already changed automatically for some reason..)

I run into an error : "Type WebApplication21.Home" already defines a member called Page_Load with the same parameter types

Thanks.

thormayer
  • 1,070
  • 6
  • 28
  • 49
  • Please add your relevant code behind code, and the header of your aspx page – Prescott Dec 16 '11 at 09:27
  • public partial class Home : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } This is what I have now.. – thormayer Dec 16 '11 at 09:31

1 Answers1

1

In the code behind (.aspx.cs) file, you need to ensure the class name has also changed.

And in the .aspx page, in the @ Page directive make sure the correct class name is used.

On another note: Why is “copy and paste” of code dangerous?

Community
  • 1
  • 1
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • public partial class Home : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } – thormayer Dec 16 '11 at 09:31
  • 1
    @user1054375 - Exactly my point. You already _have_ a `Home` class. You need to rename this one to the name of the file to avoid duplicates. – Oded Dec 16 '11 at 09:32
  • But the name of the file is "Home".. The aspx file that I copied from is "Webform1", and the new one is "Home" – thormayer Dec 16 '11 at 09:35
  • @user1054375 - And the name of the class on `Webform1`? – Oded Dec 16 '11 at 09:36