如何从代码中添加DnnCssInclude?

时间:2018-06-08 15:43:11

标签: asp.net dotnetnuke dnn-module

我一直致力于DNN主题。此时我的页面上有这个代码.ascx:

formContainer: {
    flex: 1,
    position: 'absolute'
},
backgroundImage: {
    flex: 1,
    justifyContent: 'space-between',
    alignItems: 'center',
    backgroundColor:'rgba(0,0,0,0.45)',
    width: null,
    height: null,
},

但是如何从后面的代码中添加相同的控件(page.ascx.cs)? 类似的东西:

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

1 个答案:

答案 0 :(得分:3)

您将要使用ClientResourceManager调用:

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

您需要引用

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