|
-
Apr 16th, 2003, 03:20 PM
#1
Thread Starter
Hyperactive Member
Reusing an existing form in a new project
Hi all,
How can I go about importing into a new project a form that exists in another project?
What I have is a textbox that allows people to change their information and I would like to 're-use' this form and it's functionality in a new project that I am creating.
I have tried adding a reference to the existing project and then creating an instance of the form but the form name does not appear in the intellisense..
Example is
Project 2 (NewProject) references Project 1(OldProject)
VB Code:
' Then I tried in the new project
Dim oProj as new OldProject.ExistingForm
I was hoping that I could do the above and then when a user clicked a button display the form from the old project and therefore re-use the form..
Can this be done and if so, how do I go about doing it??
Thanks
MarkusJ
-
Apr 16th, 2003, 08:43 PM
#2
PowerPoster
You can't create an instance of the page itself to show because it is a mix of HTML and code. The other reason is because ASP.Net is stateless.
What you can do if you really don't want to copy and paste (which is the easiest solution for you), is redirect to that page. Then in the destination page, have a way to tell where the user came from to do different actions based on that.
This only applies for pages though. You can include controls that you have in another project I believe. You can also use components and other classes you have in other projects.
-
Apr 16th, 2003, 09:20 PM
#3
Addicted Member
You don't even need to copy and paste if you're using vs.net. Just open up the solution explorer and right click on the project. Select add existing item, browse to your file and vs will automatically copy it into your directory. Easy.
-
Apr 16th, 2003, 10:01 PM
#4
PowerPoster
It is easy, but then in the code, if there is redirections or whatever, you will have to change it to make it work with your current project, and in turn, maybe disrupting the other project.
I think it is best to just create a new page. It doesn't take up too much space, and you can configure it exactly like you want it. Copy and paste the code you need, or just create a common class that both pages access to do the processing.
I am just thinking about the maintainability of the site.
-
Apr 16th, 2003, 10:13 PM
#5
Addicted Member
I might be misunderstanding you, but VS makes another copy on your hd and puts it in your current project's folder. Unless vs is doing something wacky, changes to the new copy won't affect the old copy. Unless I'm missing something.
Confused now.
-
Apr 16th, 2003, 11:28 PM
#6
PowerPoster
Ok, I didn't know it created a copy of the code behind page, I thought it just made a copy of the html part of it and linked to the old code behind page. Thanks for the info, that for sure would be the easy way to do it then. Then you are free to make any modifications necessary.
-
Apr 17th, 2003, 12:01 AM
#7
Thread Starter
Hyperactive Member
Cool, thanks for your help
Cheers
Markus
-
Apr 17th, 2003, 12:12 AM
#8
Addicted Member
egg all over my face
Ooops, well, er, I didn't even think about the codebehind file. Dangit. You can try adding it seperately, but I tried it and it's not working for some reason.
Sorry.
-
Apr 17th, 2003, 05:25 AM
#9
Hyperactive Member
In some ways I'm glad I'm not the only one to have this problem as it has been a pain in the neck for me too.
The way I'm managing it right now is through setting-up Visual Source Safe to share these files.
This way when project A makes a change to a file, the same change is reflected in Project B's copy.
-
Apr 17th, 2003, 09:51 AM
#10
PowerPoster
But if you create a project that just contains classes, not forms, and use those classes for the functionality of the page, you only have to edit at one place. Your web form should only contain UI type stuff and calls to the classes you built as I stated above. This way you can have many web forms accessing the same business logic. That is the way I was taught, and it seems to work pretty well for me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|