Page Templates
page 3 of 7
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 28616/ 60

Simple Page Inheritance
Simple Page Inheritance

You can probably make an educated guess at what you have to do to make a page template, but either way this first demo is going to give you a sample page for you.

Imports System
Imports
System.Web.UI
Imports
System.Web.UI.WebControls

Namespace
AGASPTemplates
Public
Class HeaderTemplate : Inherits
Page

Public
SampleText As New
Label()

Private
Sub Page_Init(ByVal sender As Object, ByVal e As
EventArgs)
Quicktext("<html><body>")
SampleText.Text = "There is no content"

Controls.Add(SampleText)
Quicktext("</body></html>")

End
Sub

Private
Sub Quicktext(ByVal text As String
)
Controls.Add(
New LiteralControl(text))
End
Sub

End
Class
End
Namespace

This looks very much like a code-behind page doesn't it? All it does is just slap together a page with a Label on it. If we add it directly as a code-behind, it will look like :

<%@ Inherits="AGASPTemplates.HeaderTemplate" Src="TemplateCode.vb" %>

Live Demo

In case you are not familiar with that line of code -

  • Inherits specifies the Page class to inherit the code from.
  • Src specified the code file to dynamically compile (with the inherited code in it). This saves you from re-compiling the file into a library every time you make a change.

 


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-03-02 8:40:32 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search