关于基础页Css样式表继承问题 在系统的,我的所有页面都继承于BasePage..在BasePage页里面的<head></head>里,我插入了一个样式表..但是从BasePage页继承下去的网页..竟然应用不了那个样式表..难道说,我每一页都要在<head></head>中插入了样式表引用吗?那"继承"这个字眼不就废了?怎么办呀? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写个BasePage类。继承pagepublic class BasePage :System.Web.UI.Page/// <summary> /// 页面加载时发生 /// </summary> protected virtual void BasePage_Load(object sender,System.EventArgs e) { if(Response.ContentType.ToLower() == "text/html") this.InsertHeader(); }/// <summary> /// 将指定的字符内容插入页面的<head>区 /// </summary> private void InsertHeader() { //获取baseWeb项脚本路径 string commonScript = "<script......></script>";//head中的脚本引用 string cssStyle = “<link...... >”//样式引用 System.Web.UI.LiteralControl literal = this.Page.Controls[0] as System.Web.UI.LiteralControl; if(literal != null) { Regex reg = new Regex(@"</title>",RegexOptions.IgnoreCase); string strHeader = literal.Text; string strFormat = "</title>\n{0}\n{1}\n"; strFormat = string.Format(strFormat,commonScript,cssStyle); literal.Text = reg.Replace(strHeader,strFormat); } } pagebase类中别忘了加上protected override void OnInit(EventArgs e) { this.Load += new System.EventHandler(this.BasePage_Load); base.OnInit(e); } @"</title>",這個@起什麽作用呢,不要的話有差別嗎 TO:回复人: jijl2001(jijl2001) 看来你对继承也不是很懂呀,呵呵..我都说了, humin1906(HJM) 的方法是可行的..再过一天我就要结贴了. winform 如何实现多表头 请问下,用C#如何读取移动硬盘的物理序列号? c#中如何知道一个过程执行完毕? 求一系列正则,谢谢正则高手 急!为什么我的C#单步执行不可以用呀?请大家帮小妹! 一个传值问题 除非DataGridView被数据绑定到支持更改通知并允许删除的IBindingList,否则不能以编程方式移除行。 .NET枚举问题(报错请输入标记符) 请问如何序列化类到数据库字段和如何反序列化? FileSystemWatcher监控文件/目录修改者 刚用ado.net,请教大家关于datagrid的问题! 自定义控件消失问题!很郁闷,求高手帮助
public class BasePage :System.Web.UI.Page
/// <summary>
/// 页面加载时发生
/// </summary>
protected virtual void BasePage_Load(object sender,System.EventArgs e)
{
if(Response.ContentType.ToLower() == "text/html")
this.InsertHeader();
}
/// <summary>
/// 将指定的字符内容插入页面的<head>区
/// </summary>
private void InsertHeader()
{
//获取baseWeb项脚本路径
string commonScript = "<script......></script>";//head中的脚本引用
string cssStyle = “<link...... >”//样式引用
System.Web.UI.LiteralControl literal =
this.Page.Controls[0] as System.Web.UI.LiteralControl;
if(literal != null)
{
Regex reg = new Regex(@"</title>",RegexOptions.IgnoreCase);
string strHeader = literal.Text;
string strFormat = "</title>\n{0}\n{1}\n";
strFormat = string.Format(strFormat,commonScript,cssStyle);
literal.Text = reg.Replace(strHeader,strFormat);
}
}
protected override void OnInit(EventArgs e)
{
this.Load += new System.EventHandler(this.BasePage_Load);
base.OnInit(e);
}