Erick Lanford Xenes
Erick Lanford Xenes

Reputation: 1572

How to add DnnCssInclude from code behind?

I have been working on a DNN Theme. At this moment I have this code on my page.ascx:

<dnn:DnnCssInclude runat="server" FilePath="css/mydnnstyles.css" PathNameAlias="SkinPath" Priority="3" />

But how can I add the same control from the code behind (page.ascx.cs)? something like:

page?.Controls.Add(new DnnCssInclude
        {
            ...
        });

Upvotes: 0

Views: 286

Answers (1)

Chris Hammond
Chris Hammond

Reputation: 8943

You'll want to use the ClientResourceManager calls:

ClientResourceManager.RegisterStyleSheet(Page, "/portals/_default/skins/PATH/FILENAME.css", FileOrder.Css.DefaultCss);

You'll need to have references to

using DotNetNuke.Web.Client;
using DotNetNuke.Web.Client.ClientResourceManagement;

Upvotes: 3

Related Questions