欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

控件開(kāi)發(fā)時(shí)兩種JS嵌入資源方式的使用方法

 更新時(shí)間:2007年04月28日 00:00:00   作者:  
第一種:
直接把要嵌入的JS文件屬性設(shè)置為“嵌入的資源”。
protected override void OnInit(EventArgs e)
{
      base.OnInit (e);
       if(!base.Page.IsStartupScriptRegistered("Script"))
        {
                Assembly assembly = typeof(TestControl).Assembly;
                StreamReader reader = null;
                 reader = new StreamReader(assembly.GetManifestResourceStream(typeof(TestControl),"test.js"));

                base.Page.RegisterStartupScript("Script",reader.ReadToEnd());

         }
}

第二種:
創(chuàng)建相同類(lèi)名的資源文件,然后在Data出的name設(shè)置為T(mén)est,value為js的內(nèi)容。

protected override void OnInit(EventArgs e)
{
      base.OnInit (e);
      if(!base.Page.IsStartupScriptRegistered("Script"))
       {
               ResourceManager resx = new ResourceManager(base.GetType());
               base.Page.RegisterStartupScript("Script",resx.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture,true,true).GetString("Test"));

        }
}
上面兩種方式都是在控件類(lèi)中輸出JS代碼,也可以自定義HttpHandler來(lái)生成Js代碼。

相關(guān)文章

最新評(píng)論