是否可以动态添加dnn:META?

时间:2018-05-03 15:29:04

标签: themes dotnetnuke

如何在我的Dnn主题上添加基于用户配置的Meta视口? 像:

如果当前用户已激活MetaViewPort 然后添加

       Select ID, Supplydate as A_SupplyDate,OrderDate as A_Orderdate,
           NULL as B_SupplyDate,NULL as B_OrderDate 
           from tbl where Category='A'
    union
       Select ID, NULL as A_SupplyDate,NULL as A_Orderdate,
           Supplydate as B_SupplyDate,OrderDate as B_OrderDate 
              from tbl where Category='B'

1 个答案:

答案 0 :(得分:1)

这是您可以通过编程或SkinObject以编程方式添加元标记的方法。请注意,这不是DNN特定的,它适用于所有aspnet网站。

HtmlMeta hm = new HtmlMeta();
hm.Attributes.Add("name", "viewport");
hm.Content = "width=device-width,initial-scale=1";
Page.Header.Controls.Add(hm);

//or if you do not have direct access to the Page object
Page page = HttpContext.Current.CurrentHandler as Page;
page.Header.Controls.Add(hm);