hello
this website applies a different masterpage based on the domain.
once the masterpage is applied i want to add different content templates that load different user controls dynamically
error is in my class file
Compilation Error Type 'BreadCrumb' is not defined.
below is my code
--------------
test.aspx
<%@ Page Language="vb" EnableViewState="false" AutoEventWireup="false" MasterPageFile="~/MasterPages/Website.Master" CodeBehind="test.aspx.vb" Inherits="Website.test" %>
<%@ Reference Control="~/Controls/BreadCrumb.ascx" %>
---------------
test.aspx.vb
Public Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
'code to determine domain and apply correct masterpage (irrelevant to the question)
Dim m As New ApplyMasterPage
Me.Page.MasterPageFile = m.MasterLocation.ToString()
MyBase.AddContentTemplate("BreadCrumbContent", New ApplyBreadCrumbContent)
End Sub
End Class
--------------
App_Code/ApplyBreadCrumbContent.vb
Public Class ApplyBreadCrumbContent
Implements System.Web.UI.ITemplate
Dim b As BreadCrumb 'error here
Dim p As Page
Sub InstantiateIn(ByVal container As Control) Implements System.Web.UI.ITemplate.InstantiateIn
b = CType(p.LoadControl("~/Controls/BreadCrumb.ascx"), BreadCrumb)
container.Controls.Add(b)
End Sub
End Class
---------------
BreadCrumb.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="BreadCrumb.ascx.vb" Inherits="Website.BreadCrumb" %>
'contains a repeater control
--------------------------
BreadCrumb.ascx.vb
Public Partial Class BreadCrumb
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'contains data to render the repeater
End Sub
End Class
------------------
MasterPage contains a ContentPlaceHolder
<asp:ContentPlaceHolder ID="BreadCrumbContent" runat="server"></asp:ContentPlaceHolder>
Below url give some information
http://www.asp.net/(S(wnmvzu45umnszm455c1qs522))/learn/ajax-videos/video-286.aspx
http://www.aspfree.com/c/a/ASP.NET/Dynamically-Loading-User-Controls-in-ASPNET/