I have to create 2 webparts which have 40% same functionality. Now I am making the first one and finding a way to clone that project in order to do the second one fast.

Is it possible to clone a webpart project with no any risk (project guid..)?

  • The 40% that's shared between the webparts, is it UI or functionality? – Mohamed Derhalli Dec 8 '16 at 6:37

No direct way to clone webpart, because when you create a webpart project, many files are being structured based on project templated selected and this files have many refereces to uniquie guid which are pertaining to components used in your project.

You need to create a empty webpart and copy the code manually below are main components which can be copied.

  1. Ascx code - Basically the html code, make sure you are not replacing namespace reference which are referring current webpart(mostly first 4,5 tags)
  2. Code behind(ascx.cs) - Copy the code of all the events manually inside 2nd webpart. If there are any new class definition inside this file, this also has to be copied.
  3. Any reference to class should work if namespace is same and it is being referred from same solution.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.