Template Web page

G

Guest

I have quite a few of web pages in my project which would have similar
appearance (like header, some

images, color, footer etc).

How do i create one base template web page and have all other web pages
derive from it, so that
when i have to do some changes to apperance of all web pages i would just
change base template form,

rather than all web pages.

this seems possible in windows forms but in case of web form where UI is
separated from code behind,

how to implement it?

any help is appreciated.

Thanks in advance.
 
D

Diane Wilson

I have quite a few of web pages in my project which would have similar
appearance (like header, some

images, color, footer etc).

How do i create one base template web page and have all other web pages
derive from it, so that
when i have to do some changes to apperance of all web pages i would just
change base template form,

rather than all web pages.

this seems possible in windows forms but in case of web form where UI is
separated from code behind,

how to implement it?

any help is appreciated.

Thanks in advance.
For all the good things that Visual Studio does, it is not a good
general-purpose web-site development tool. for that, you need either
Dreamweaver (from Macromedia) or GoLive (from Adobe). Both support
templates exactly as you describe them. Both also support reusable
components (like user controls in ASP.NET); change the component,
and all pages that use them are updated.

I'm going to start exploring how to make this work in a practical
mode over the next few days as I start converting old Perl-based
forms in my site to ASP.NET. My first pass at solving the problem
will be to create an empty form in Visual Studio, using flow layout,
and save it. Then I'll open it in GoLive and build a template.
Then I'll create a new .aspx page from the template (in GoLive),
save it, and do the ASP.NET editing in Visual Studio.

One thing that's going to be interesting is that my site page
structure has a search field on every page. This requires a
form, independent from anything else in the page. ASP.NET
limits you to one form element per page, so for.aspx pages,
I'll have to add a button-click event handler for the search
button that will construct a URL from the search arguments
and do a Response.Redirect to the search engine. This event
handler will in effect become part of the "template" but since
it will live in the code-behind page for every .aspx page,
and needs to be part of the page subclass, handling that is
going to be a little tricky. Maybe I need to create a
subclass of system.web.ui.page, put the event handler there,
and have all my template-based.aspx pages subclass off my
page class.

Another thing that will require manual intervention is creating
the .cs and .resx files for each page created from the template.
I don't see a way to automate that yet.

We'll see..... I'm open to suggestions and ideas.

Diane

Diane
 
B

Brock Allen

The idea of a template is supported in ASP.NET 2.0 with Master Pages. If
this is a must have feature for you, I'd suggest not wasting your time with
a v1.x approach and move to v2.0.
 
K

KMA

It's not hard to make templates, or base pages, with v1.x.

IIRC there's a great article on 4guysfromrolla about this. He builds in code
for visitor tracking into the base class.

The key seems to be in having the base page add panels (header, links,
content, footer etc) then have the derived pages add (user)controls to the
panels.

It takes care of the single form issue too. The base class adds the form.
Derived classes need not worry about adding a form.

The only "downside" is that derived pages must have all their html code
deleted. Remove all except the page declarations, otherwise the resultant
output has two BODY tags etc.

The time saving in the long-run is enormous.

Of course, I'm sure MS has picked up on this hence Master Pages, but not all
shared hosts have moved to v2 yet, not are likely to do so for some time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top