So let's say you wanted to make a copy of a Web Form page within a .Net Project.
Is there an easier way than:
- Copy Source Page
- Page Source Page within project to get new page
- Exclude Source Page
- Rename code behind class for new page
- Add Source Page Back
Sometimes I miss something obvious is there a better way to do this? I know the next question would be "Why are you copying code within a project instead for reusing it?" Let's just say that's a secret;).
From stackoverflow
-
I do this:
- Select the original ASPX file in solution explorer
- Ctrl+C followed by Ctrl+V (quick copy paste)
- Rename new ASPX file (let's say NewFile.aspx)
- Rename code-behind class name to NewFile
- Rename
Inherits
attribute ofPage
directive within HTML to end with 'NewFile' - (Optional) If you moved the page into a different folder, you'll need to update the Namespace references in the HTML's
Page
directive as well as in the code-behind.
wonderchook : The only reason I added the extra step of removing is on occasion I've had problems were the references get confused on the rename. Maybe there is something weird I do that I'm not noticing.Kon : strange.. I've never had that issue. :/ -
Can you make that form a User Control, and then insert it as needed? Then you can save yourself the trouble of editing every instance of it that you copy.
wonderchook : I thought about this, there are instances where I do this. Unfortunately I don't think it will work in this case. -
- Create new page via "Add New Item"
- Copy original markup (minus Page declaration) and paste into new page
- Copy code from original code-behind and paste into the new code-behind
0 comments:
Post a Comment