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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with inheritance Web Template

Status
Not open for further replies.

jw970170

Programmer
Aug 8, 2005
38
Hello,

I have found an 'easy' tutorial for setting up web templates ( but cannot get it to work. Any ideas?

Here is my code. I think the mistake is some obvious little thing


------------------------TPage.vb------------------------
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls

Public Class TPage : Inherits System.Web.UI.Page

Dim Form As HtmlForm = New HtmlForm
Protected Overrides Sub CreateChildControls()
Me.Controls.Add(Me.Form)

Dim main As Control = Me.FindControl("Main")
If IsDBNull(main) Then
Me.Form.Controls.Add(main)
End If

MyBase.CreateChildControls()

End Sub
Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
Output.Write("<html> <head><title>[Website Title]</title> </head><body>fdghdghd")

' Render the page contents.
MyBase.Render(Output)

' Render the end HTML.
Output.Write("</body></html>")
End Sub

End Class
--------------------Webform1.aspx-------------------------
<%@ Page %>

<!-- Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Page.WebForm1"> -->

<asp:panel ID=”Main”> <BR>add your page specific content here...
<BR>notice the ID of the panel <BR></asp:panel>
--------------------Page.aspx.vb-------------------------
Public Class Page : Inherits TPage

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class
 
I should mention that I created this by creating a vb.net web project. I then added a new class (TPage). I noticed that TPage did not appear to generate a dll so I created a new web component project based entirely on TPage...compilied it and then put it in the bin directory of webform1
 
ok, for anyone wondering about templates, I solved the problem.

First, I renamed one of the classes back to the original name ( page became WebForm1),

and I also put the original
<%@Page %> heading to <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Page.WebForm1"%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top