ASP .NET - Wrapping my page with a header and footer

alocurto

Platinum Member
Nov 4, 1999
2,174
0
76
I have a bunch of user input forms I have created using asp .net. They all require code behind them and all that jazz. All of them work but they look like a standard HTML form.

I have a header and a footer (THAT HAS FORMS IN THEM THEMSELVES) I want to put on all my pages. The header and footer will wrap around the current form(s) I have and line up the forms right smack dab in a table cell between the header and footer. Back in my day I would do an include on header.asp/php/whatever and an include on the footer. DOn't seem like I can do that now.

Apparently I need to make user controls b/c that is how everything is done in asp.net. Does anyone do ASP .NET dev a lot? Can you just give me a little light on how this is to be done. This a very common thing in the web world and I can't seem to find the right/proper/anyway to do it in asp .net.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
In php you would just do <?php require('header.php')?><?php require('footer.php')?> don't know about ASP
 

alocurto

Platinum Member
Nov 4, 1999
2,174
0
76
Yeah, I know how to do that in php and asp and all that but ASP .NET it a whole nother monkey.
 

hellman69

Member
Feb 15, 2003
180
0
71
Good news is you are right, you can make user controls. Then you register them on every page, just like includes. The only thing to watch out for is those forms in the header and footer can't have the runat="server" attribute on them. (Only one is allowed per page). If you need to pass variables to those, then you need to setup public properties for them in the user controls and on the main page, you will have to set them.

It is a little different, but not much. You just need to bang your head againist the keyboard a few times, and eventually you'll get it.

Trevor
 

alocurto

Platinum Member
Nov 4, 1999
2,174
0
76
cool, as long as I know am banging my head on something I can break through. Thanks for the response.