ispiro
ispiro

Reputation: 27703

How can I make a copy of a folder in a website?

I have a couple of web pages in a folder, and want to copy the folder to have a set of similar pages (with only a couple of changes).

However, when I simply copy and paste it in Visual Web Developer I get errors:

Type 'WebApplication1.Folder1.WebForm1' already defines a member called 'Page_Load' with the same parameter types

And:

The type 'WebApplication1.Folder1.WebForm1' already contains a definition for 'form1'

So how do I make a copy, where the namespace or class name isn't exactly the same - Is there a way to let Visual Studio do it for me? If not - What should I change to have it work but not break the code?

EDIT:

Here's what I did:

  1. New project
  2. Asp.net web application
  3. Added folder to project
  4. Added webform to folder
  5. Folder right-click copy
  6. Project right-click paste
  7. F5
  8. Got errors

Upvotes: 2

Views: 202

Answers (1)

fowlermatthewd
fowlermatthewd

Reputation: 173

In the copied folder, you have to change a few things.

  1. in the copied version WebForm1.aspx.cs code behind, change the namespace to something new. From namespace WebApplication1.Folder1 to namespace WebApplication1.NewFolder1
  2. in the markup of WebForm1.aspx of the copied file, you need to change the "inherits" property of the page. It should change from Inherits="WebApplication1.Folder1.WebForm1" to Inherits="WebApplication1.NewFolder1.WebForm1".
  3. you should change the namespace in any of file that was copied over as well, but if you just have an empty webform, then the first 2 steps should get you going.

There might be an automatic way to do all of this, (find and replace could work, or some other VS feature) , but i don't know about it.

Upvotes: 2

Related Questions