I have a similar, but different requirement.
I need a portal to dynamically load a skin based on a user selection from a list of available skins. I read an interesting article which suggested creating a "proxyskin.ascx" file and use that as the portal default skin. Basically the Skin Proxy determines which user selected skin to use and then attempts to load a user control (ie a skin) of that name as follows:-
SkinProxy.ascx
<%@ Control language="vb" CodeBehind="~/admin/Skins/skin.vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim UserSkin As String = "someuserskinchoice.ascx"
Controls.Add(LoadControl(UserSkin))
Catch ex As Exception
Controls.Add(LoadControl("Default.ascx"))
End Try
End Sub
</script>
In this pseudo code, some logic is executed to determine the name of the user selected skin. Then an attempt is made to load a control whose name matches that skin name. If unsuccessful, a control named Default.ascx is loaded.
This sounds like it should work, but I get the following error:-
AssemblyVersion: 04.09.00
PortalID: 7
PortalName: Pro-Ma Retail Store
UserID: 2
UserName: admin
ActiveTabID: 1375
ActiveTabName: Custom1
RawURL: /Default.aspx?tabid=1375&error=Object+reference+not+set+to+an+instance+of+an+object.&content=0
AbsoluteURL: /Default.aspx
AbsoluteURLReferrer:
UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 7385000e-1e1d-4416-8180-135ddcb2cfbf
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: DotNetNuke.UI.Skins.Skin.Page_Init
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Skins.Skin.Page_Init(Object sender, EventArgs e) at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at ASP.portals__default_skins_nifosspwine_skinproxy_ascx.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
Source:
Server Name: STAGING
Anyone know what's wrong with this????