Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-using web forms 1

Status
Not open for further replies.

mit99mh

Programmer
Sep 24, 2002
246
GB
Can anyone point me to a resource that explains how to re-sue web forms - the reason I'm asking is that in the web app I'm working on several forms are duplicated and I assume their exists a mechanism for re-using / building forms on the fly in .NET and would like to be pointed to any resources.

Any help much appreciated
 
Why not simply use the same form each time? Maybe show/hide the appropriate buttons based on the page needs?

Post more details and we might be able to offer more suggestions.

Mark
 
You can copy the form...then select the project and say "Paste" then you just have to change the name in the code behind page because that will still say the old page's name...

DLC
 
i was thinking more from an OO point of view - writing base classes ect that could be re-used.

 
mit99mh,

Using a base class is pretty common is asp.net. First create a class that inherits from System.Web.UI.Page. Then, in your code-behind classes, inherit from this class instead of System.Web.UI.Page. This way, you can re-use funtionality on each page.

This works great for functions and non-ui related methods that you want to occur or be called from each page, but it gets tricky when you try to do visual inheritance (reusing controls, layouts, etc.) the way you can with windows forms.

In that case, it is probably better to build up a page by using user-controls that can be used thoughout the site. (Even your layout can be a user control)

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top