Richard West Richard West - 7 days ago 5
C# Question

Best way to make duplicate copies of existing ASPX page in Visual Studio

What is the best way to create a copy of an existing ASPX page in a web project in Visual Studio?

If I right click on the ASPX file in the Solution Explorer and select copy, then paste, it looks like what I was expecting. I get a new copy of the ASPX file and the code behind files. I can then rename the ASPX file and the code behind files get renamed as well.

Looking good, until I open the ASPX file. Then I see that it has the same "Inherits" tag that the original file had, and it points to the orginal class name.

Is there something that I am missing? I realize I can mannually edit this, and the code behind files (since they are declaring the same class name, which causes build errors). Is there a better way to do this, or should I just man up and start doing some manual work? :-)

Answer

I almost always create a brand new page, then just copy the "guts" (leaving page directive info, namespaces, etc) followed shortly by some find and replace if needed.

Comments