首页 新闻 会员 周边

关于Page.Header.Controls.Add的奇怪问题

0
[已关闭问题]

      我在页面动态引用css、js. 

代码
Response.Write("<link href='images/style.css' type=text/css rel=stylesheet>");
Response.Write(
"<script type='text/javascript' src='../js/jquery.js'></script>");
Response.Write(
"<script type='text/javascript' src='../js/jsdate.js'></script>");
Response.Write(
"<script language='JavaScript' src='../Js/admin.js'></SCRIPT>");

 

这样输出在页面的顶部了, 效果是正常的, 但不利于标准。 于是我便用Page.Header.Controls.Add 添加进<head>里面, 全码如下:

代码
var jquery = new HtmlGenericControl("script");
jquery.Attributes[
"type"] = "text/javascript";
jquery.Attributes[
"src"] = "../js/jquery.js";
Page.Header.Controls.Add(jquery);

var admin
= new HtmlGenericControl("script");
admin.Attributes[
"type"] = "text/javascript";
admin.Attributes[
"src"] = "../js/admin.js";
Page.Header.Controls.Add(admin);


var style
= new HtmlGenericControl("link");
style.Attributes[
"href"] = "images/style.css";
style.Attributes[
"type"] = "text/css";
style.Attributes[
"rel"] = "stylesheet";
style.Attributes[
"href"] = "images/style.css";
Page.Header.Controls.Add(style);

 

 

   运行后, 在html源码里面可以看到<head>里面已经加了这些东西了, 但为什么css没有效果? 而引用的JS文件又正常的。。。 为什么为什么? 实在找不到哪里出问题了! 希望有人帮下忙, 虽然没分…………

问题补充: 用firebug调试了, 根本就没有引用进来。。。 不知道是为什么~!!!!! 我在界面上写死都有问题了。。。 太奇怪了, 在顶部输入就没问题, 写在其它任何地方都有问题。。。
问天何必的主页 问天何必 | 老鸟四级 | 园豆:3311
提问于:2010-05-16 12:31
< >
分享
其他回答(1)
0

自己测试了没有问题,你多写了一个“style.Attributes["href"] = "images/style.css";”但这也没有影响的。用Firebug调试一下。

Astar | 园豆:40805 (高人七级) | 2010-05-17 09:20
0

呃~~~

我也碰到了类似的问题,楼主你是怎么解决的啊?

谢谢!

骆驼祥子 | 园豆:115 (初学一级) | 2011-11-07 10:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册