| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1694 人关注过本帖
标题:BS结构重实现页面间的继承的问题
取消只看楼主 加入收藏
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
结帖率:98.25%
收藏
 问题点数:0 回复次数:10 
BS结构重实现页面间的继承的问题
我想在BS结构中实现页面间的继承,该怎么做啊,
例如我在a.aspx中实现的功能,在b.aspx中也想实现a.aspx的功能
谢谢大家了

[此贴子已经被作者于2006-3-7 16:47:41编辑过]

搜索更多相关主题的帖子: 结构 页面 继承 
2006-03-07 15:06
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
顶上来,有人会吗?

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-07 16:48
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
楼上这个办法我已经试过了,出错。
在CS结构中楼上的方法是可行的,但是BS结构中就不行了
(BS结构是浏览器的程序)

[此贴子已经被作者于2006-3-8 14:45:06编辑过]


本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 14:43
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 

未将对象引用设置到对象的实例。

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:

行 77: 		private void InitializeComponent()
行 78: 		{    
行 79: 			this.educeButton.Click += new System.EventHandler(this.educeButton_Click);
行 80: 			this.addUserLink.Click += new System.EventHandler(this.addUserLink_Click);
行 81: 			this.emailListLink.Click += new System.EventHandler(this.emailListLink_Click);

源文件: e:\email\dataeduce.aspx.cs 行: 79

堆栈跟踪:

[NullReferenceException: 未将对象引用设置到对象的实例。]
   Email.DataEduce.InitializeComponent() in e:\email\dataeduce.aspx.cs:79
   Email.DataEduce.OnInit(EventArgs e) in e:\email\dataeduce.aspx.cs:69
   Email.WebForm1.OnInit(EventArgs e) in e:\email\emaillist.aspx.cs:77
   System.Web.UI.Control.InitRecursive(Control namingContainer)
   System.Web.UI.Page.ProcessRequestMain()


版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 14:47
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
那什么时候才能继承呢,或者说我可能什么地方没注意到。
我在a.aspx中定义了3个LinkButton,然后想在b.aspx中继承这3个LinkButton,用过你说的办法,出现这个错误。

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 15:01
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
是protected的,难道必须是public的?

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 15:13
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 

//Landing.aspx
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;

namespace Email
{
/// <summary>
/// Landing 的摘要说明。
/// </summary>
public class Landing : System.Web.UI.Page
{
public System.Web.UI.WebControls.Button landingButton;
public System.Web.UI.WebControls.TextBox userNameText;
public System.Web.UI.WebControls.TextBox passwordText;
public System.Web.UI.WebControls.Label Label1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{}
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.landingButton.Click += new System.EventHandler(this.landingButton_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void landingButton_Click(object sender, System.EventArgs e)
{
string connString = ConfigurationSettings.AppSettings["connString"];
SqlConnection conn = new SqlConnection(connString);
conn.Open();

try
{
string sqlSelect = "select * from jbdy_Login where UserName = '"+ userNameText.Text.ToString() +"' " +
" and Password = '"+ passwordText.Text.ToString() +"'";
SqlCommand comm = new SqlCommand(sqlSelect, conn);
SqlDataReader reader = comm.ExecuteReader();
if(reader.Read())
{
Session["userName"] = reader["UserName"].ToString();
Session["Password"] = reader["Password"].ToString();
Session["DepartId"] = reader["DepartId"].ToString();

Response.Redirect("EmailList.aspx");
}
else
{
Label1.Text = "用户名或密码错误!";
}
}
finally
{
conn.Close();
}
}
}
}


//WebForm2.aspx
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Email
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : Landing
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

这是程序。


本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 15:18
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 

未将对象引用设置到对象的实例。

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:

行 47: 		private void InitializeComponent()
行 48: 		{
行 49: 			this.landingButton.Click += new System.EventHandler(this.landingButton_Click);
行 50: 			this.Load += new System.EventHandler(this.Page_Load);
行 51: 

源文件: e:\email\landing.aspx.cs 行: 49

堆栈跟踪:

[NullReferenceException: 未将对象引用设置到对象的实例。]
   Email.Landing.InitializeComponent() in e:\email\landing.aspx.cs:49
   Email.Landing.OnInit(EventArgs e) in e:\email\landing.aspx.cs:39
   Email.WebForm2.OnInit(EventArgs e) in e:\email\webform2.aspx.cs:31
   System.Web.UI.Control.InitRecursive(Control namingContainer)
   System.Web.UI.Page.ProcessRequestMain()


版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

这是报错信息

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 15:19
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
我想我知道了,因为我用的WebForm2.aspx继承的是一个页面,而不是一个类.

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 15:43
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
对,我就是想把控件也继承过来,我估计要想继承控件,就只能把父类生成.DLL文件了,我还没试过,只是猜测,不知道ytyt654你试过吗?

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2006-03-08 16:12
快速回复:BS结构重实现页面间的继承的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013217 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved