嵌入css文件和javascript文件方法

[assembly: WebResource("Erp.Web.WebControls.DatePicker.Resources.DatePicker.js", "application/x-javascript", PerformSubstitution = true)]
[assembly: WebResource("Erp.Web.WebControls.DatePicker.Resources.DatePicker.css", "text/css", PerformSubstitution = true)]


 资源文件

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    this.Page.ClientScript.RegisterClientScriptInclude("DatePicker.js", this.ResolveClientUrl("~/WebControls/DatePicker/Resources/DatePicker.js"));

    
    HtmlLink link = new HtmlLink();
    link.Href = "~/WebControls/DatePicker/Resources/DatePicker.css";
    link.Attributes.Add("rel", "stylesheet");
    link.Attributes.Add("type", "text/css");
    Page.Header.Controls.Add(link);

}

 

脚本文件:

this.Page.ClientScript.RegisterClientScriptInclude("ext-base.js", this.ResolveClientUrl("~/Admin/ExtJS/adapter/ext/ext-base.js"));
this.Page.ClientScript.RegisterClientScriptInclude("ext-all.js", this.ResolveClientUrl("~/Admin/ExtJS/ext-all.js"));


 


 

当然对应文件夹下肯定要有DatePicker.css和DatePicker.js

 

你可能感兴趣的:(嵌入css文件和javascript文件方法)