Best way to copy a web form page within a project?

So let's say you wanted to make a copy of a web form page in a .NET project.

Is there an easier way:

  • Copy source page
  • Page source page inside project to get new page
  • Exclude source page
  • Rename code by class for new page
  • Add original page Back

Sometimes I am missing something obvious, is there a better way to do this? I know the next question is, "Why are you copying the code inside the project and not reusing it?" Let's just say it's a secret;).


source to share

3 answers

I'm doing it:

  • Select the original ASPX file in the solution explorer
  • Ctrl + C followed by Ctrl + V (quick copy)
  • Rename the new ASPX file (say NewFile.aspx)
  • Rename the code class name to NewFile
  • Rename the Inherits

    directive attribute Page

    to HTML for completion with "NewFile"
  • (Optional) If you moved the page to a different folder, you will need to update the namespace references in the HTML directive Page

    as well as in the code.


  • Create a new page via "Add new item"
  • Copy the original markup (minus the page declaration) and paste it into the new page
  • Copy code from source and paste into new code



Can you make this User Control form and then insert it as needed? Then you can save yourself the trouble of editing every instance you copy.



All Articles