Reflection to load a page?

F

Fredrik Melin

Using Framwork 2.0
Im trying to load a page through reflection (To allow developers at the
cutomer to override a single page without us knowing it in a precompiled
site)

This code works fine

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim MyAssembly As Reflection.Assembly
Dim oItem As Page

MyAssembly = Reflection.Assembly.LoadFile("c:\Documents and
Settings\Mel\My Documents\Visual Studio
2005\Projects\WebSite1\PrecompiledWeb\WebSite1\bin\App_Web_btf81rpr.dll")
If Not MyAssembly Is Nothing Then
oItem = CType(MyAssembly.CreateInstance("ASP.override_aspx",
True), Page)
End If

End Sub


But how do I show the newly loaded page? Does anyone know if its possible?
Ive tried the basic .RenderControl etc, but it seems that I need to do
something more before that with the page to initialize it.

Tips are welcome.

- Fredrik
 
K

Karl Seguin

This seems a little off.

Why not simply dynamically load a user control and place it on the page?
The page can have nothing more than a placeholder for the user control.

dim control as Control = Page.LoadControl("~/controls/" +
WhateverTheUserWants)
page.controlHolder.Controls.Add(control)

Karl
 

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

Top