Template based solution in asp.net

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

In almost all websites which I have developed, we need to follow a
layout template (header, footer, menu on left hand side etc)

In ASP.NET solutions, we can do this in two ways

1) use user controls.

But frankly, making a "control" which renders a table of width 100% with
a gif somehow to me it seems wrong. I would create a control to
encapsulate a particular piece of functionality or component. Not really
to control the page layout.

Secondly if I am changing the layout tomorrow (maybe I found a better
javascript tree library) then I have to rebuild recompile the user control.

2) Use a common base class for Code behind classes.

This is also good. but then the layout gets tied up with C# code. and
therefore, layout change would mean getting a C# programmer first.

Is there some better way of implementing templates or site look and
feel. Why not specify the layout of a page in an XML format. and then
the asp.engine doing its rendering only into a specific portion as
specified in the XML. So that If I find a better tree control I just
change the xml file so that the new javascript tree menu gets included.

regards,
Abhishek.
 
You may find it worthwhile to check out how the templates are
implemented in the ASP.NET forums (http://www.asp.net/).

Regarding the user controls - if you have a header and a footer user
control, you wouldn't have to necessarily render a table of width 100% -
just literally render whatever HTML you'd want appearing on each page.
And if you don't use CodeBehind (which you probably won't need in the
UserControl anyway - because its just acting as a template), then you
won't need to recompile - you'll just have to upload the modified
UserControl.
 
Back
Top