I've been searching the forums here for a way to programmatially assign a skin and really think I've got it figured out, but I'm getting some buggyness and error messages that make me think it's not just right yet. Can anyone shed some light on this?
Here is the skin file I've selected for the portal. Very simple at this point:
<%@ Control Language="VB" ClassName="DynamicSkin" Inherits="DotNetNuke.UI.Skins.Skin" %>
<asp:PlaceHolder ID="SkinHolder" runat="server" />
<script runat="server">
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
SkinHolder.Controls.Add(LoadControl("skin1.ascx"))
End Sub
</script>
Here is the "skin1.ascx" that this file references:
<%@ Control Language="VB" ClassName="Skin1" Inherits="DotNetNuke.UI.Skins.Skin" %>
<div id="ControlPanel" runat="server" />
<div id="TopPane" runat="server" />
<div id="ContentPane" runat="server" />
<div id="BottomPane" runat="server" />
As you can see, I hope, I am trying to have the first file (dynamicskin.ascx) load and apply skin1.ascx (same folder) to the page. It appears to be working correctly except for these things:
1. I have two control panel div's. Even though there is not one specified in dynamicskin.ascx, it's still appearing there. However, if I remove that line from skin1.ascx, the page errors out with "Object reference not set to an instance of an object" on the line of code that adds the skin as a control.
2. At the bottom of my page, I have errors that appear to be one for each module on the page. In host mode, they say "DotNetNuke.Services.Exceptions.ModuleLoadException: Cannot locate ContentPane for Skin." In logged-out mode, they say "Unhandled error loading module"... Yet I can still place controls in "TopPane", "ContentPane", and "BottomPane" and they seem to work correctly.
Am I missing something obvious?
FYI... I've tried moving the Page_Init Code to Page_Load - same result. I read something about a Page_PreInit event but I don't see that event as an option.
This is very similar to the resolution discussed here, which I believe is what I have implemented.