• 动态引入js文件和css样式表文件


    在开发web项目的过程中,总会碰到用户控件 .ascx 和页面,或者页面和母版页的很多关系。用局部的页面

    动态地给母版页引入js文件或者样式表文件,或者在用户控件里面根据需要动态引入js文件和样式表会比较好。

    以下是我引入的一个方法:
               // 引入js文件
                HtmlGenericControl scriptControl = new HtmlGenericControl("script");
                scriptControl.Attributes.Add("type", "text/javascript");
                scriptControl.Attributes.Add("language", "JavaScript");
                scriptControl.Attributes.Add("src", "http://images.dayoo.com/travel/9208.files/changeimg.js");
                Page.Header.Controls.Add(scriptControl);
                // 引入样式表
                 Literal cssControl = new Literal();
                cssControl.Text = "<link href=\"http://images.dayoo.com/photo/17358.files/css.css\" rel=\"stylesheet\" type=\"text/css\"/>";
                Page.Header.Controls.Add(cssControl);

    以上代码在页面或者控件的PageLoad里面。
  • 相关阅读:
    二次离线莫队
    串串题-各种算法的应用
    插头dp 笔记
    ST03模拟赛#1 比赛记录
    AtCoder Regular Contest 123 比赛记录(vp)
    冷门trick:线性区间单调求和
    dp优化瞎吹
    概率期望
    NOI挑战赛#2 (vp) 记录
    动态规划-线性dp-序列组成-5833. 统计特殊子序列的数目
  • 原文地址:https://www.cnblogs.com/worldreason/p/1234331.html
Copyright © 2020-2023  润新知